/*
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 { MarkerSeries } from "./MarkerSeries";
import { Base, Type, runOn, Number_$type, enumGetBox, typeCast, Point_$type, fromEnum, markType } from "igniteui-angular-core/ES2015/type";
import { PolarAxisInfoCache } from "./PolarAxisInfoCache";
import { SeriesRenderer$2 } from "./SeriesRenderer$2";
import { PolarFrame } from "./PolarFrame";
import { DependencyProperty } from "igniteui-angular-core/ES2015/DependencyProperty";
import { NumericAngleAxis } from "./NumericAngleAxis";
import { NumericRadiusAxis } from "./NumericRadiusAxis";
import { TrendLineType_$type } from "igniteui-angular-core/ES2015/TrendLineType";
import { Brush } from "igniteui-angular-core/ES2015/Brush";
import { PenLineCap_$type } from "igniteui-angular-core/ES2015/PenLineCap";
import { DoubleCollection } from "igniteui-angular-core/ES2015/DoubleCollection";
import { List$1 } from "igniteui-angular-core/ES2015/List$1";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-angular-core/ES2015/Rect";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { PolarAxes } from "./PolarAxes";
import { IFastItemsSource_$type } from "igniteui-angular-core/ES2015/IFastItemsSource";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { AxisRange } from "./AxisRange";
import { HashPool$2 } from "igniteui-angular-core/ES2015/HashPool$2";
import { Clipper } from "igniteui-angular-core/ES2015/Clipper";
import { Dictionary$2 } from "igniteui-angular-core/ES2015/Dictionary$2";
import { OwnedPoint } from "./OwnedPoint";
import { PolarTrendLineManager } from "./PolarTrendLineManager";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { PropertyMetadata } from "igniteui-angular-core/ES2015/PropertyMetadata";
import { isNaN_, isInfinity } from "igniteui-angular-core/ES2015/number";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { GeometryGroup } from "igniteui-angular-core/ES2015/GeometryGroup";
import { stringIsNullOrEmpty } from "igniteui-angular-core/ES2015/string";
/**
 * @hidden
 */
export class PolarBase extends MarkerSeries {
    constructor() {
        super();
        this.m0 = null;
        this.mt = null;
        this.my = null;
        this.oq = null;
        this.op = null;
        this.m6 = null;
        this.m8 = null;
        this.m9 = null;
        this.m3 = new PolarFrame();
        this.m5 = new PolarFrame();
        this.m2 = new PolarFrame();
        this.mx = null;
        this.m4 = null;
        this.m1 = null;
        this.m4 = new PolarFrame();
        this.m5.x = runOn(this, this.oo);
        this.m3.x = runOn(this, this.oo);
        this.m2.x = runOn(this, this.oo);
        this.m6 = new SeriesRenderer$2(PolarFrame.$, PolarBaseView.$, 0, runOn(this, this.n1), runOn(this, this.n3), runOn(this, this.ca), runOn(this, this.jd), runOn(this, this.nz));
    }
    bf() {
        return new PolarBaseView(this);
    }
    im(a) {
        super.im(a);
        this.mz = a;
    }
    hn() {
        super.hn();
        this.mv = null;
        this.mw = null;
    }
    get_c0() {
        return true;
    }
    nf(a) {
        if (!this.hasMarkers) {
            return false;
        }
        let b = this.mv;
        let c = new ScalerParams(1, this.bs.mq, this.lq, b.b8);
        c.c = this.getEffectiveViewport1(this.bi);
        let d = this.mw;
        let e = new ScalerParams(1, this.bs.mq, this.lq, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.ls.cc((f) => {
            if (f._visibility == 0) {
                let g = new SeriesPointOfInterest();
                let h = f.n;
                let i = f.o;
                if (h < this.lq.left || h > this.lq.right || i < this.lq.top || i > this.lq.bottom) {
                    return;
                }
                g.b = b.dw(h, c);
                g.c = d.dw(i, e);
                g.a = f.content;
                a.add(g);
            }
        });
        return true;
    }
    nz() {
        if (this.bt.g) {
            this.bt.t();
        }
    }
    n0() {
        this.mx.e(this.m0.w, this.na, this.nb, this.oq, this.op, (a, b) => Math.cos(b), (a, b) => Math.sin(b), true);
    }
    get na() {
        return this.m8;
    }
    set na(a) {
        if (this.m8 != a) {
            let b = this.na;
            this.m8 = a;
            this.raisePropertyChanged("AngleColumn", b, this.na);
        }
    }
    get nb() {
        return this.m9;
    }
    set nb(a) {
        if (this.m9 != a) {
            let b = this.nb;
            this.m9 = a;
            this.raisePropertyChanged("RadiusColumn", b, this.nb);
        }
    }
    get oj() {
        return this.c(PolarBase.n4);
    }
    set oj(a) {
        this.h(PolarBase.n4, a);
    }
    h4() {
        super.h4();
        if (this.mw != null) {
            this.mw.g0(false);
        }
        if (this.mv != null) {
            this.mv.g0(false);
        }
    }
    hs(a, b, c, d) {
        let e = false;
        this.mz.cr.g$e(a, b, c, d);
        if (this.mv != null && !this.mv.ck()) {
            e = true;
        }
        if (this.mw != null && !this.mw.ck()) {
            e = true;
        }
        if (e) {
            this.i5(true);
        }
    }
    jk(a, b) {
        this.i5(false);
    }
    jl(a, b) {
        this.i5(false);
    }
    dv(a, b, c) {
        let d = true;
        if (!super.dv(a, b, c) || !c.l() || b.isEmpty || a.isEmpty || this.mv == null || this.mw == null || this.na == null || this.nb == null || this.na.count == 0 || this.nb.count == 0 || this.bz == null || this.bz.count != this.na.count || this.bz.count != this.nb.count || this.mx == null || this.mv.bf == null || this.mw.bf == null || this.mv.jx == this.mv.jw || this.mw.jx == this.mw.jw) {
            d = false;
        }
        return d;
    }
    i6(a) {
        let b;
        let c;
        let d = this.getViewInfo(c, b);
        c = d.p0;
        b = d.p1;
        if (!this.dv(c, b, this.bi)) {
            this.hp(true, this.bi);
            return;
        }
        this.oq = b;
        this.op = c;
        this.my = new PolarAxisInfoCache(this.mv, this.mw, this.bz);
        let e = new SeriesRenderingArguments(this, c, b, a, this.dd);
        let f = this.m6.g(e, this.m3, this.m2, this.m5, this.mz);
        this.m3 = f.p1;
        this.m2 = f.p2;
        this.m5 = f.p3;
    }
    oo(a) {
        let b = this.mx.h(a.x, a.y, this.oq, this.op, this.my.e, this.my.d, this.my.g, this.my.f, this.my.i, this.my.h);
        return b;
    }
    an(a) {
        if (a != null && a == this.mv && this.na != null) {
            return new AxisRange(this.na.minimum, this.na.maximum);
        }
        if (a != null && a == this.mw && this.nb != null) {
            return new AxisRange(this.nb.minimum, this.nb.maximum);
        }
        return null;
    }
    c8(a) {
        let b = this.bi.bs;
        b = b.copy();
        let c = this.bi.br;
        let d = !b.isEmpty && !c.isEmpty && this.bz != null ? this.bz.indexOf(a) : -1;
        if (this.mv == null || this.na == null || this.mw == null || this.nb == null) {
            return false;
        }
        if (d < 0 || d > this.na.count - 1 || d > this.nb.count - 1) {
            return false;
        }
        let e = this.mv.getScaledAngle(this.na.item(d));
        let f = this.mw.li(this.nb.item(d));
        let g = 0.5 + (Math.cos(e) * f);
        let h = 0.5 + (Math.sin(e) * f);
        if (!isNaN_(g)) {
            if (g < b.left + 0.1 * b.width) {
                g = g + 0.4 * b.width;
                b.x = g - 0.5 * b.width;
            }
            if (g > b.right - 0.1 * b.width) {
                g = g - 0.4 * b.width;
                b.x = g - 0.5 * b.width;
            }
        }
        if (!isNaN_(h)) {
            if (h < b.top + 0.1 * b.height) {
                h = h + 0.4 * b.height;
                b.y = h - 0.5 * b.height;
            }
            if (h > b.bottom - 0.1 * b.height) {
                h = h - 0.4 * b.height;
                b.y = h - 0.5 * b.height;
            }
        }
        if (this.bn != null) {
            this.bn.ap(this.bs, b, true);
        }
        return d >= 0;
    }
    fm(a) {
        return null;
    }
    e5(a) {
        return -1;
    }
    ag() {
        return [this.mv, this.mw];
    }
    is(a, b, c, d) {
        super.is(a, b, c, d);
        if (this.mz.cr.g$b(a, b, c, d)) {
            this.i5(false);
            this.ic();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.na);
                    c.deregisterColumn(this.nb);
                    this.na = null;
                    this.nb = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.na = this.bw(this.no);
                    this.nb = this.bw(this.nu);
                }
                if ((this.mw != null && !this.mw.ck()) || (this.mv != null && !this.mv.ck())) {
                    this.i5(false);
                }
                break;
            case PolarBase.$$p[0]:
                if (this.mv != null && this.mw != null) {
                    this.mx = new PolarAxes(this.mw, this.mv);
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if (this.mv != null && !this.mv.ck()) {
                    this.i5(false);
                }
                else if (c != null && d == null) {
                    this.hp(true, this.bi);
                }
                break;
            case PolarBase.$$p[4]:
                if (this.mv != null && this.mw != null) {
                    this.mx = new PolarAxes(this.mw, this.mv);
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if (this.mw != null && !this.mw.ck()) {
                    this.i5(false);
                }
                else if (c != null && d == null) {
                    this.hp(true, this.bi);
                }
                if (this.mv != null && !this.mv.ck()) {
                    this.mv.gw();
                }
                break;
            case PolarBase.$$p[1]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.na);
                    this.na = this.bw(this.no);
                }
                break;
            case "AngleColumn":
                this.mz.cr.g$i();
                if (this.mv != null && !this.mv.ck()) {
                    this.i5(false);
                }
                break;
            case PolarBase.$$p[5]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.nb);
                    this.nb = this.bw(this.nu);
                }
                break;
            case "RadiusColumn":
                this.mz.cr.g$i();
                if (this.mw != null && !this.mw.ck()) {
                    this.i5(false);
                }
                break;
            case PolarBase.$$p[6]:
                this.i5(false);
                this.ic();
                break;
            case PolarBase.$$p[3]:
                this.i5(false);
                this.ic();
                break;
            case "TransitionProgress":
                this.my = new PolarAxisInfoCache(this.mv, this.mw, this.bz);
                this.oq = this.bi.bs;
                this.op = this.bi.br;
                this.m5.v = this.ng;
                this.m5.c(this.ew, this.m3, this.m2);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.ew == 1) {
                    this.n3(this.m2, this.mz);
                }
                else {
                    this.n3(this.m5, this.mz);
                }
                if (this.bs != null) {
                    this.bs.jj(this);
                }
                break;
            case "TrendLineBrush":
                this.jg();
                break;
            case PolarBase.$$p[2]:
                this.i5(false);
                this.ic();
                break;
            case "TrendLineType":
                this.ic();
                break;
        }
    }
    nd(a) {
        if (typeCast(NumericRadiusAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    nc(a) {
        if (typeCast(NumericAngleAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    hp(a, b) {
        super.hp(a, b);
        let c = b;
        if (a) {
            c.cs.clear();
        }
        c.cr.g$d();
    }
    mu(a, b) {
        let c = a.top - 10;
        let d = a.bottom + 10;
        let e = a.left - 10;
        let f = a.right + 10;
        let g = ((() => {
            let $ret = new Clipper(1, e, d, f, c, false);
            $ret.i = b;
            return $ret;
        })());
        return g;
    }
    ny(a, b, c, d) {
        a.g = new Dictionary$2(Base.$, OwnedPoint.$, 1, b);
        let e = this.bz;
        for (let f = 0; f < b; f++) {
            let g = a.w._inner[f];
            if (!isInfinity(g.x) && !isInfinity(g.y)) {
                let h = { $type: Point_$type, x: this.na.item(f), y: this.nb.item(f) };
                let i = { $type: Point_$type, x: g.x, y: g.y };
                a.g.addItem(e.item(f), ((() => {
                    let $ret = new OwnedPoint();
                    $ret.a = e.item(f);
                    $ret.b = h;
                    $ret.c = i;
                    return $ret;
                })()));
            }
        }
    }
    n1(a, b) {
        let c = b.bs;
        let d = b.br;
        a.j.clear();
        a.n.clear();
        let e = Math.min(this.na != null ? this.na.count : 0, this.nb != null ? this.nb.count : 0);
        if (e < 1) {
            return;
        }
        this.my = new PolarAxisInfoCache(this.mv, this.mw, this.bz);
        this.m0 = a;
        this.op = d;
        this.oq = c;
        b.cp.l(a.j, this.nj, c, d, this.er);
        if (e <= this.nj) {
            this.ny(a, e, c, d);
        }
        let f = this.mu(d, a.n);
        let g = Math.min(this.mv.jx, this.mv.jw);
        let h = Math.max(this.mv.jw, this.mv.jx);
        b.cr.q = this.ng;
        b.cr.p = 0;
        b.cr.s = this.mw.lc;
        b.cr.r = this.mw.lb;
        b.cr.t = (i, j) => this.mx.c(i, j, c, d, Math.cos);
        b.cr.u = (i, j) => this.mx.d(i, j, c, d, Math.sin);
        let i = new List$1(Number_$type, 0);
        for (let j = 0; j < this.na.count; j++) {
            if (this.na.item(j) >= g && this.na.item(j) <= h) {
                i.add(this.na.item(j));
            }
        }
        let k = this.nb;
        if (i.count != this.na.count) {
            k = new List$1(Number_$type, 0);
            for (let l = 0; l < this.na.count; l++) {
                if (this.na.item(l) >= g && this.na.item(l) <= h) {
                    k.add(this.nb.item(l));
                }
            }
        }
        b.cr.v(a.n, this.m7, i, k, this.nk, runOn(this.mv, this.mv.getScaledAngle), runOn(this.mw, this.mw.li), ((() => {
            let $ret = new TrendResolutionParams();
            $ret.b = this.er;
            $ret.f = d;
            $ret.g = c;
            return $ret;
        })()), f, g, h);
    }
    n3(a, b) {
        let c = b.bs;
        let d = b.br;
        let e = this.getEffectiveViewport1(b);
        let f = this.li(b);
        this.my = new PolarAxisInfoCache(this.mv, this.mw, this.bz);
        b.cp.j(a.j, this.lx);
        b.cj();
        let g = this.mu(d, b.cr.g$j.aj);
        b.cr.g$h(a.n, g);
        this.nx(d, c, e, f, b);
    }
    nx(a, b, c, d, e) {
        e.cu(a, b, c, d);
    }
    jg() {
        super.jg();
        if (this.fe < 0) {
            return;
        }
        this.mz.cw();
    }
    i7(a, b) {
        super.i7(a, b);
        if (!this.dk) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh)) {
            return;
        }
        let c = this.bh;
        if (!this.de) {
            this.m4 = new PolarFrame();
            this.n1(this.m4, c);
        }
        this.de = false;
        this.n3(this.m4, c);
        this.dk = false;
    }
    i4(a, b, c, d, e) {
        super.i4(a, b, c, d, e);
        let f = this.a0.a$h.item(d);
        let g = f;
        f.ay(c);
        if (this.cc(g)) {
            return;
        }
        if (this.m1 == null) {
            this.m1 = new PolarFrame();
        }
        this.n1(this.m1, g);
        this.n3(this.m1, g);
    }
    n2(a, b) {
        let c = new List$1(Base.$, 0);
        for (let d of fromEnum(b.c)) {
            if (!a.containsKey(d)) {
                c.add1(d);
            }
        }
        for (let e of fromEnum(c)) {
            b.g(e);
        }
    }
    ms(a, b, c) {
        this.n0();
        return this.m0.w.toArray();
    }
    nh(a) {
        let b = new List$1(Number_$type, 0);
        let c = this.bz;
        for (let d of fromEnum(this.mz.cs.c)) {
            b.add(c.indexOf(d));
        }
        return b;
    }
    on(a) {
        return { $type: Point_$type, x: this.na.item(a), y: this.nb.item(a) };
    }
    hy(a) {
        super.hy(a);
        this.a2.exportTrendlineData(this, a, this.mz.cr.g$j);
    }
}
PolarBase.$t = markType(PolarBase, 'PolarBase', MarkerSeries.$);
PolarBase.n4 = DependencyProperty.i("ActualTrendLineBrush", Brush.$, PolarBase.$, new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
Type.dep(DependencyProperty, PropertyMetadata, PolarBase, 'raisePropertyChanged', ['AngleAxis:mv:n5', [NumericAngleAxis.$, null], 'AngleMemberPath:no:n6', [2], 'ClipSeriesToBounds:ne:n7', [0, false], 'MaximumMarkers:nj:n8', [1, 400], 'RadiusAxis:mw:n9', [NumericRadiusAxis.$, null], 'RadiusMemberPath:nu:oa', [2], 'UseCartesianInterpolation:ng:oi', [0, true], 'TrendLineType:m7:og', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness:ni:of', [1, 1.5], 'TrendLinePeriod:nk:oe', [1, 7], 'TrendLineZIndex:nl:oh', [1, 1], 'TrendLineBrush:ok:ob', [Brush.$, null], 'TrendLineDashArray:ol:oc', [DoubleCollection.$], 'TrendLineDashCap:om:od', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
/**
 * @hidden
 */
export class PolarBaseView extends MarkerSeriesView {
    constructor(a) {
        super(a);
        this.cq = null;
        this.cp = null;
        this.cr = null;
        this.cs = null;
        this.cq = a;
        this.cs = new HashPool$2(Base.$, Marker.$);
        this.ce(this.cs);
        this.cr = new PolarTrendLineManager();
    }
    ap() {
        super.ap();
        this.cp = this.co();
        if (!this.n) {
            this.cq.nj = 1000;
            this.by.lt = 2;
        }
    }
    co() {
        let a = new NumericMarkerManager(0, (b) => this.cs.item(b), (b) => this.cq.my.c.item(b), runOn(this, this.cv), runOn(this, this.cn), runOn(this, this.ct));
        a.n = true;
        a.p = runOn(this.cq, this.cq.on);
        return a;
    }
    cv(a) {
        this.cq.n2(a, this.cs);
    }
    cn() {
        return this.cq.ms(this.cs, this.bs, this.br);
    }
    ct() {
        return this.cq.nh(this.cs);
    }
    cu(a, b, c, d) {
        if (this.cq.ne) {
            let e = new GeometryGroup();
            this.cq.mw.lq(e, a, b, c, d);
        }
        else {
        }
    }
    cw() {
        if (this.cq.ok != null) {
            this.cq.oj = this.cq.ok;
        }
        else {
            this.cq.oj = this.cq.kv;
        }
    }
    cc(a) {
        this.cs.f(a);
    }
    a2(a, b) {
        if (a.d) {
            if (this.cq.m7 != 0 && !b) {
                let c = this.cr.g$j;
                c.ac = this.cq.ni;
                c._stroke = this.cq.oj;
                c.ad = this.cq.om;
                c.ai = this.cq.ol;
                a.u(c);
            }
        }
        super.a2(a, b);
    }
    cx() {
        return Rect.empty;
    }
    getDefaultTooltipTemplate() {
        let a = "<div class='ui-chart-default-tooltip-content'><span>" + "${item." + this.cq.no + "}" + "</span><br/><span";
        let b = this.e.a0.a$q(this.e);
        if (!stringIsNullOrEmpty(b)) {
            a += " style='color:" + b + "'";
        }
        a += ">" + this.cq.fs + ": </span><span class='ui-priority-primary'>" + "${item." + this.cq.nu + "}</span></div>";
        return a;
    }
}
PolarBaseView.$t = markType(PolarBaseView, 'PolarBaseView', MarkerSeriesView.$);
//# sourceMappingURL=PolarBase_combined.js.map