/*
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 { Brush } from "igniteui-angular-core/ES2015/Brush";
import { DependencyProperty } from "igniteui-angular-core/ES2015/DependencyProperty";
import { Series } from "./Series";
import { Thickness } from "igniteui-angular-core/ES2015/Thickness";
import { Visibility_$type } from "igniteui-angular-core/ES2015/Visibility";
import { CrosshairLayerFrame } from "./CrosshairLayerFrame";
import { List$1 } from "igniteui-angular-core/ES2015/List$1";
import { Axis } from "./Axis";
import { Dictionary$2 } from "igniteui-angular-core/ES2015/Dictionary$2";
import { Pool$1 } from "igniteui-angular-core/ES2015/Pool$1";
import { AxisAnnotation } from "./AxisAnnotation";
import { Type, Number_$type, enumGetBox, fromEnum, Point_$type, markType, runOn } from "igniteui-angular-core/ES2015/type";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { Tuple$2 } from "igniteui-angular-core/ES2015/Tuple$2";
import { Path } from "igniteui-angular-core/ES2015/Path";
import { PathGeometry } from "igniteui-angular-core/ES2015/PathGeometry";
import { PathFigure } from "igniteui-angular-core/ES2015/PathFigure";
import { LineSegment } from "igniteui-angular-core/ES2015/LineSegment";
import { PropertyMetadata } from "igniteui-angular-core/ES2015/PropertyMetadata";
import { isNaN_ } from "igniteui-angular-core/ES2015/number";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { TranslateTransform } from "igniteui-angular-core/ES2015/TranslateTransform";
import { LineGeometry } from "igniteui-angular-core/ES2015/LineGeometry";
import { BrushUtil } from "igniteui-angular-core/ES2015/BrushUtil";
/**
 * @hidden
 */
export class CrosshairLayer extends AnnotationLayer {
    constructor() {
        super();
        this.xAxisAnnotationFormatLabel = null;
        this.yAxisAnnotationFormatLabel = null;
        this.m4 = null;
        this.m3 = null;
        let a = new CrosshairLayerFrame();
        let b = new CrosshairLayerFrame();
        let c = new CrosshairLayerFrame();
        let d = this.ff / 1000;
        this.lu = a;
        this.lt = b;
        this.lv = c;
        this.ab = CrosshairLayer.$;
    }
    bf() {
        return new CrosshairLayerView(this);
    }
    im(a) {
        super.im(a);
        this.mw = a;
    }
    my() {
        return this.xAxisAnnotationFormatLabel != null;
    }
    mz() {
        return this.yAxisAnnotationFormatLabel != null;
    }
    get o8() {
        return new Thickness(1, this.m6, this.m8, this.m7, this.m5);
    }
    get o9() {
        return new Thickness(1, this.nb, this.nd, this.nc, this.na);
    }
    mb(a, b) {
        if (this.mx == null || this.mx == a) {
            if (!this.aq.c) {
                this.i5(b);
            }
        }
    }
    md(a, b) {
        super.md(a, b);
        let c = a;
        let d = this.m2;
        let e = this.m1;
        c.ad.clear();
        c.ae.clear();
        c.ac.clear();
        c.af.clear();
        AxisAnnotationFrameManager.b(c);
        if (this.ly(this.mx)) {
            this.n8(this.mx, c, d, e);
        }
        else {
            for (let f of fromEnum(this.bs.series)) {
                if (this.ly(f)) {
                    this.n8(f, c, d, e);
                }
            }
        }
    }
    ly(a) {
        if (!super.ly(a)) {
            return false;
        }
        let b = this.l6(a);
        if (!b.c) {
            return false;
        }
        return true;
    }
    ig() {
        super.ig();
        if (!this.aq.c && !this.ca()) {
            return;
        }
        if (this.ca()) {
            this.n9(this.lv, false);
        }
        else {
            this.n9(this.lt, false);
        }
    }
    n8(a, b, c, d) {
        let e = this.l6(a);
        if (!e.c) {
            return;
        }
        let f = e.d;
        f = a.ld(f, c, d);
        let g = this.kv;
        if (g == null) {
            g = this.kx;
        }
        if (g == null) {
            g = a.kv;
            if (g != null) {
                g = this.mw.b8(g);
            }
        }
        let h = g;
        let i = g;
        if (this.o0 != null) {
            h = this.o0;
        }
        if (this.o1 != null) {
            i = this.o1;
        }
        b.ac.add(h);
        b.af.add(i);
        b.ad.add(f.y);
        b.ae.add(f.x);
        if (this.m0) {
            AxisAnnotationFrameManager.c(b, f, a, this.bs, this.getEffectiveViewport(), g, this.o2, this.o4, this.o3, this.o8, this.m9, this.o5, this.o7, this.o6, this.o9, this.ne, this.pb == 0, this.pa == 0);
        }
    }
    n9(a, b) {
        let c = false;
        if (this.m3 == null) {
            c = true;
            this.m4 = new List$1(Axis.$, 0);
            this.m3 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        AxisAnnotationFrameManager.d(this, a, c, this.m3, this.m4, b, this.nf, this.ng, this.xAxisAnnotationFormatLabel, this.yAxisAnnotationFormatLabel);
    }
    n7(a, b, c, d, e) {
        let f = a.item(b);
        b++;
        if (e) {
            f._stroke = d.af._inner[c];
            f._fill = d.af._inner[c];
        }
        else {
            f._stroke = d.ac._inner[c];
            f._fill = d.ac._inner[c];
        }
        f.ac = this.ev;
        f.ai = this.k3;
        f.ad = this.k4;
        return new Tuple$2(Path.$, Number_$type, f, b);
    }
    mg(a, b) {
        super.mg(a, b);
        let c = this.mw.b2;
        let d = a;
        let e = d.ad.count;
        let f = 0;
        let g = b.br.left;
        let h = b.br.right;
        let i = b.br.top;
        let j = b.br.bottom;
        let k = this.pb == 0;
        let l = this.pa == 0;
        for (let m = 0; m < e; m++) {
            let n = Math.floor(d.ad._inner[m]);
            let o = Math.floor(d.ae._inner[m]);
            let p = null;
            if (k) {
                if (isNaN_(n)) {
                    continue;
                }
                let q = this.n7(c, f, m, d, true);
                p = q.c;
                f = q.d;
                let r = new PathGeometry();
                let s = new PathFigure();
                s._startPoint = { $type: Point_$type, x: o, y: i };
                let t = new LineSegment(1);
                t.c = { $type: Point_$type, x: o, y: j };
                s._segments.add(t);
                r.b.add(s);
                p.aj = r;
            }
            if (l) {
                if (isNaN_(n)) {
                    continue;
                }
                let u = this.n7(c, f, m, d, false);
                p = u.c;
                f = u.d;
                let v = new PathGeometry();
                let w = new PathFigure();
                w._startPoint = { $type: Point_$type, x: g, y: n };
                let x = new LineSegment(1);
                x.c = { $type: Point_$type, x: h, y: n };
                w._segments.add(x);
                v.b.add(w);
                p.aj = v;
            }
        }
        c.count = f;
        if (this.ca()) {
            this.n9(this.lv, true);
        }
        else {
            this.n9(this.lt, false);
        }
    }
    c7() {
        return true;
    }
    is(a, b, c, d) {
        super.is(a, b, c, d);
        switch (b) {
            case CrosshairLayer.$$p[1]:
                this.i5(true);
                break;
            case CrosshairLayer.$$p[7]:
                this.i5(true);
                break;
            case CrosshairLayer.$$p[4]:
                this.i5(true);
                break;
            case CrosshairLayer.$$p[2]:
            case CrosshairLayer.$$p[8]:
            case CrosshairLayer.$$p[10]:
            case CrosshairLayer.$$p[12]:
            case CrosshairLayer.$$p[14]:
            case CrosshairLayer.$$p[13]:
            case CrosshairLayer.$$p[11]:
            case CrosshairLayer.$$p[15]:
            case CrosshairLayer.$$p[16]:
            case CrosshairLayer.$$p[17]:
            case CrosshairLayer.$$p[19]:
            case CrosshairLayer.$$p[21]:
            case CrosshairLayer.$$p[23]:
            case CrosshairLayer.$$p[22]:
            case CrosshairLayer.$$p[20]:
            case CrosshairLayer.$$p[24]:
            case CrosshairLayer.$$p[25]:
            case CrosshairLayer.$$p[0]:
            case CrosshairLayer.$$p[6]:
            case CrosshairLayer.$$p[5]:
                this.i5(true);
                break;
        }
    }
}
CrosshairLayer.$t = markType(CrosshairLayer, 'CrosshairLayer', AnnotationLayer.$);
Type.dep(DependencyProperty, PropertyMetadata, CrosshairLayer, 'raisePropertyChanged', ['HorizontalLineStroke:o0:oa', [Brush.$, null], 'HorizontalLineVisibility:pa:ob', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'IsAxisAnnotationEnabled:m0:oc', [0, false], 'SkipUnknownValues:m1:od', [0, true], 'TargetSeries:mx:oe', [Series.$, null], 'UseInterpolation:m2:of', [0, true], 'VerticalLineStroke:o1:og', [Brush.$, null], 'VerticalLineVisibility:pb:oh', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'XAxisAnnotationBackground:o2:oi', [Brush.$, null], 'XAxisAnnotationInterpolatedValuePrecision:nf:oj', [1, -1], 'XAxisAnnotationOutline:o3:ok', [Brush.$, null], 'XAxisAnnotationPaddingBottom:m5:ol', [1, NaN], 'XAxisAnnotationPaddingLeft:m6:om', [1, NaN], 'XAxisAnnotationPaddingRight:m7:on', [1, NaN], 'XAxisAnnotationPaddingTop:m8:oo', [1, NaN], 'XAxisAnnotationStrokeThickness:m9:op', [1, NaN], 'XAxisAnnotationTextColor:o4:oq', [Brush.$, null], 'YAxisAnnotationBackground:o5:or', [Brush.$, null], 'YAxisAnnotationInterpolatedValuePrecision:ng:os', [1, -1], 'YAxisAnnotationOutline:o6:ot', [Brush.$, null], 'YAxisAnnotationPaddingBottom:na:ou', [1, NaN], 'YAxisAnnotationPaddingLeft:nb:ov', [1, NaN], 'YAxisAnnotationPaddingRight:nc:ow', [1, NaN], 'YAxisAnnotationPaddingTop:nd:ox', [1, NaN], 'YAxisAnnotationStrokeThickness:ne:oy', [1, NaN], 'YAxisAnnotationTextColor:o7:oz', [Brush.$, null]]);
/**
 * @hidden
 */
export class CrosshairLayerView extends AnnotationLayerView {
    constructor(a) {
        super(a);
        this.b1 = null;
        this.b2 = null;
        this.b3 = null;
        this.b1 = a;
        this.b3 = new List$1(Path.$, 0);
    }
    ap() {
        super.ap();
        this.b2 = ((() => {
            let $ret = new Pool$1(Path.$);
            $ret.create = runOn(this, this.b9);
            $ret.activate = runOn(this, this.b4);
            $ret.disactivate = runOn(this, this.b6);
            $ret.destroy = runOn(this, this.b5);
            return $ret;
        })());
    }
    b9() {
        let a = new Path();
        a.j = new TranslateTransform();
        this.b3.add(a);
        return a;
    }
    b4(a) {
        a._visibility = 0;
    }
    b6(a) {
        a._visibility = 1;
    }
    b5(a) {
        this.b3.remove(a);
    }
    b7(a, b, c, d) {
        if (a.aj == null || a.aj.b.x != d || a.aj.c.x != c) {
            let e = ((() => {
                let $ret = new LineGeometry();
                $ret.c = { $type: Point_$type, x: c, y: b };
                $ret.b = { $type: Point_$type, x: d, y: b };
                return $ret;
            })());
            a.aj = e;
        }
    }
    b8(a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.h(a, 0.1);
    }
    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.s(d);
                }
            }
        }
    }
    ai(a) {
        super.ai(a);
        for (let b = 0; b < this.b3.count; b++) {
            this.e.a2.exportPathData(a, this.b3._inner[b], "crosshairLine", ["Main", "Crosshair"]);
        }
    }
}
CrosshairLayerView.$t = markType(CrosshairLayerView, 'CrosshairLayerView', AnnotationLayerView.$);
//# sourceMappingURL=CrosshairLayer_combined.js.map