/*
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.m7 = null;
        this.m0 = null;
        this.m5 = null;
        this.ox = null;
        this.ow = null;
        this.nd = null;
        this.nf = null;
        this.ng = null;
        this.na = new PolarFrame();
        this.nc = new PolarFrame();
        this.m9 = new PolarFrame();
        this.m4 = null;
        this.nb = null;
        this.m8 = null;
        this.nb = new PolarFrame();
        this.nc.x = runOn(this, this.ov);
        this.na.x = runOn(this, this.ov);
        this.m9.x = runOn(this, this.ov);
        this.nd = new SeriesRenderer$2(PolarFrame.$, PolarBaseView.$, 0, runOn(this, this.n8), runOn(this, this.oa), runOn(this, this.ca), runOn(this, this.jk), runOn(this, this.n6));
    }
    bf() {
        return new PolarBaseView(this);
    }
    it(a) {
        super.it(a);
        this.m6 = a;
    }
    ht() {
        super.ht();
        this.m2 = null;
        this.m3 = null;
    }
    get_c0() {
        return true;
    }
    nm(a) {
        if (!this.hasMarkers) {
            return false;
        }
        let b = this.m2;
        let c = new ScalerParams(1, this.bs.mq, this.lx, b.b8);
        c.c = this.getEffectiveViewport1(this.bi);
        let d = this.m3;
        let e = new ScalerParams(1, this.bs.mq, this.lx, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.lz.cc((f) => {
            if (f._visibility == 0) {
                let g = new SeriesPointOfInterest();
                let h = f.n;
                let i = f.o;
                if (h < this.lx.left || h > this.lx.right || i < this.lx.top || i > this.lx.bottom) {
                    return;
                }
                g.b = b.dy(h, c);
                g.c = d.dy(i, e);
                g.a = f.content;
                a.add(g);
            }
        });
        return true;
    }
    n6() {
        if (this.bt.g) {
            this.bt.t();
        }
    }
    n7() {
        this.m4.e(this.m7.w, this.nh, this.ni, this.ox, this.ow, (a, b) => Math.cos(b), (a, b) => Math.sin(b), true);
    }
    get nh() {
        return this.nf;
    }
    set nh(a) {
        if (this.nf != a) {
            let b = this.nh;
            this.nf = a;
            this.raisePropertyChanged("AngleColumn", b, this.nh);
        }
    }
    get ni() {
        return this.ng;
    }
    set ni(a) {
        if (this.ng != a) {
            let b = this.ni;
            this.ng = a;
            this.raisePropertyChanged("RadiusColumn", b, this.ni);
        }
    }
    get oq() {
        return this.c(PolarBase.ob);
    }
    set oq(a) {
        this.h(PolarBase.ob, a);
    }
    ia() {
        super.ia();
        if (this.m3 != null) {
            this.m3.g5(false);
        }
        if (this.m2 != null) {
            this.m2.g5(false);
        }
    }
    hy(a, b, c, d) {
        let e = false;
        this.m6.cr.g$e(a, b, c, d);
        if (this.m2 != null && !this.m2.ck()) {
            e = true;
        }
        if (this.m3 != null && !this.m3.ck()) {
            e = true;
        }
        if (e) {
            this.jc(true);
        }
    }
    jr(a, b) {
        this.jc(false);
    }
    js(a, b) {
        this.jc(false);
    }
    dw(a, b, c) {
        let d = true;
        if (!super.dw(a, b, c) || !c.l() || b.isEmpty || a.isEmpty || this.m2 == null || this.m3 == null || this.nh == null || this.ni == null || this.nh.count == 0 || this.ni.count == 0 || this.bz == null || this.bz.count != this.nh.count || this.bz.count != this.ni.count || this.m4 == null || this.m2.bf == null || this.m3.bf == null || this.m2.j3 == this.m2.j2 || this.m3.j3 == this.m3.j2) {
            d = false;
        }
        return d;
    }
    jd(a) {
        let b;
        let c;
        let d = this.getViewInfo(c, b);
        c = d.p0;
        b = d.p1;
        if (!this.dw(c, b, this.bi)) {
            this.hv(true, this.bi);
            return;
        }
        this.ox = b;
        this.ow = c;
        this.m5 = new PolarAxisInfoCache(this.m2, this.m3, this.bz);
        let e = new SeriesRenderingArguments(this, c, b, a, this.de);
        let f = this.nd.g(e, this.na, this.m9, this.nc, this.m6);
        this.na = f.p1;
        this.m9 = f.p2;
        this.nc = f.p3;
    }
    ov(a) {
        let b = this.m4.h(a.x, a.y, this.ox, this.ow, this.m5.e, this.m5.d, this.m5.g, this.m5.f, this.m5.i, this.m5.h);
        return b;
    }
    an(a) {
        if (a != null && a == this.m2 && this.nh != null) {
            return new AxisRange(this.nh.minimum, this.nh.maximum);
        }
        if (a != null && a == this.m3 && this.ni != null) {
            return new AxisRange(this.ni.minimum, this.ni.maximum);
        }
        return null;
    }
    c9(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.m2 == null || this.nh == null || this.m3 == null || this.ni == null) {
            return false;
        }
        if (d < 0 || d > this.nh.count - 1 || d > this.ni.count - 1) {
            return false;
        }
        let e = this.m2.getScaledAngle(this.nh.item(d));
        let f = this.m3.lo(this.ni.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;
    }
    fp(a) {
        return null;
    }
    e8(a) {
        return -1;
    }
    ag() {
        return [this.m2, this.m3];
    }
    fs(a, b) {
        let c = this.gu(b);
        if (c == PolarBase.$$p[1]) {
            return this.ft(a, b, this.nv);
        }
        if (c == PolarBase.$$p[5]) {
            return this.ft(a, b, this.n1);
        }
        return super.fs(a, b);
    }
    iy(a, b, c, d) {
        super.iy(a, b, c, d);
        if (this.m6.cr.g$b(a, b, c, d)) {
            this.jc(false);
            this.ij();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.nh);
                    c.deregisterColumn(this.ni);
                    this.nh = null;
                    this.ni = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.nh = this.bw(this.nv);
                    this.ni = this.bw(this.n1);
                }
                if ((this.m3 != null && !this.m3.ck()) || (this.m2 != null && !this.m2.ck())) {
                    this.jc(false);
                }
                break;
            case PolarBase.$$p[0]:
                if (this.m2 != null && this.m3 != null) {
                    this.m4 = new PolarAxes(this.m3, this.m2);
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if (this.m2 != null && !this.m2.ck()) {
                    this.jc(false);
                }
                else if (c != null && d == null) {
                    this.hv(true, this.bi);
                }
                break;
            case PolarBase.$$p[4]:
                if (this.m2 != null && this.m3 != null) {
                    this.m4 = new PolarAxes(this.m3, this.m2);
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if (this.m3 != null && !this.m3.ck()) {
                    this.jc(false);
                }
                else if (c != null && d == null) {
                    this.hv(true, this.bi);
                }
                if (this.m2 != null && !this.m2.ck()) {
                    this.m2.g1();
                }
                break;
            case PolarBase.$$p[1]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.nh);
                    this.nh = this.bw(this.nv);
                }
                break;
            case "AngleColumn":
                this.m6.cr.g$i();
                if (this.m2 != null && !this.m2.ck()) {
                    this.jc(false);
                }
                break;
            case PolarBase.$$p[5]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.ni);
                    this.ni = this.bw(this.n1);
                }
                break;
            case "RadiusColumn":
                this.m6.cr.g$i();
                if (this.m3 != null && !this.m3.ck()) {
                    this.jc(false);
                }
                break;
            case PolarBase.$$p[6]:
                this.jc(false);
                this.ij();
                break;
            case PolarBase.$$p[3]:
                this.jc(false);
                this.ij();
                break;
            case "TransitionProgress":
                this.m5 = new PolarAxisInfoCache(this.m2, this.m3, this.bz);
                this.ox = this.bi.bs;
                this.ow = this.bi.br;
                this.nc.v = this.nn;
                this.nc.c(this.ez, this.na, this.m9);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.ez == 1) {
                    this.oa(this.m9, this.m6);
                }
                else {
                    this.oa(this.nc, this.m6);
                }
                if (this.bs != null) {
                    this.bs.jj(this);
                }
                break;
            case "TrendLineBrush":
                this.jn();
                break;
            case PolarBase.$$p[2]:
                this.jc(false);
                this.ij();
                break;
            case "TrendLineType":
                this.ij();
                break;
        }
    }
    nk(a) {
        if (typeCast(NumericRadiusAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    nj(a) {
        if (typeCast(NumericAngleAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    hv(a, b) {
        super.hv(a, b);
        let c = b;
        if (a) {
            c.cs.clear();
        }
        c.cr.g$d();
    }
    m1(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;
    }
    n5(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.nh.item(f), y: this.ni.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;
                })()));
            }
        }
    }
    n8(a, b) {
        let c = b.bs;
        let d = b.br;
        a.j.clear();
        a.n.clear();
        let e = Math.min(this.nh != null ? this.nh.count : 0, this.ni != null ? this.ni.count : 0);
        if (e < 1) {
            return;
        }
        this.m5 = new PolarAxisInfoCache(this.m2, this.m3, this.bz);
        this.m7 = a;
        this.ow = d;
        this.ox = c;
        b.cp.l(a.j, this.nq, c, d, this.eu);
        if (e <= this.nq) {
            this.n5(a, e, c, d);
        }
        let f = this.m1(d, a.n);
        let g = Math.min(this.m2.j3, this.m2.j2);
        let h = Math.max(this.m2.j2, this.m2.j3);
        b.cr.q = this.nn;
        b.cr.p = 0;
        b.cr.s = this.m3.li;
        b.cr.r = this.m3.lh;
        b.cr.t = (i, j) => this.m4.c(i, j, c, d, Math.cos);
        b.cr.u = (i, j) => this.m4.d(i, j, c, d, Math.sin);
        let i = new List$1(Number_$type, 0);
        for (let j = 0; j < this.nh.count; j++) {
            if (this.nh.item(j) >= g && this.nh.item(j) <= h) {
                i.add(this.nh.item(j));
            }
        }
        let k = this.ni;
        if (i.count != this.nh.count) {
            k = new List$1(Number_$type, 0);
            for (let l = 0; l < this.nh.count; l++) {
                if (this.nh.item(l) >= g && this.nh.item(l) <= h) {
                    k.add(this.ni.item(l));
                }
            }
        }
        b.cr.v(a.n, this.ne, i, k, this.nr, runOn(this.m2, this.m2.getScaledAngle), runOn(this.m3, this.m3.lo), ((() => {
            let $ret = new TrendResolutionParams();
            $ret.b = this.eu;
            $ret.f = d;
            $ret.g = c;
            return $ret;
        })()), f, g, h);
    }
    oa(a, b) {
        let c = b.bs;
        let d = b.br;
        let e = this.getEffectiveViewport1(b);
        let f = this.lp(b);
        this.m5 = new PolarAxisInfoCache(this.m2, this.m3, this.bz);
        b.cp.j(a.j, this.l4);
        b.cj();
        let g = this.m1(d, b.cr.g$j.aj);
        b.cr.g$h(a.n, g);
        this.n4(d, c, e, f, b);
    }
    n4(a, b, c, d, e) {
        e.cu(a, b, c, d);
    }
    jn() {
        super.jn();
        if (this.fh < 0) {
            return;
        }
        this.m6.cw();
    }
    je(a, b) {
        super.je(a, b);
        if (!this.dl) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh)) {
            return;
        }
        let c = this.bh;
        if (!this.df) {
            this.nb = new PolarFrame();
            this.n8(this.nb, c);
        }
        this.df = false;
        this.oa(this.nb, c);
        this.dl = false;
    }
    jb(a, b, c, d, e) {
        super.jb(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.m8 == null) {
            this.m8 = new PolarFrame();
        }
        this.n8(this.m8, g);
        this.oa(this.m8, g);
    }
    n9(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);
        }
    }
    mz(a, b, c) {
        this.n7();
        return this.m7.w.toArray();
    }
    no(a) {
        let b = new List$1(Number_$type, 0);
        let c = this.bz;
        for (let d of fromEnum(this.m6.cs.c)) {
            b.add(c.indexOf(d));
        }
        return b;
    }
    ou(a) {
        return { $type: Point_$type, x: this.nh.item(a), y: this.ni.item(a) };
    }
    h4(a) {
        super.h4(a);
        this.a2.exportTrendlineData(this, a, this.m6.cr.g$j);
    }
}
PolarBase.$t = markType(PolarBase, 'PolarBase', MarkerSeries.$);
PolarBase.ob = 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:m2:oc', [NumericAngleAxis.$, null], 'AngleMemberPath:nv:od', [2], 'ClipSeriesToBounds:nl:oe', [0, false], 'MaximumMarkers:nq:of', [1, 400], 'RadiusAxis:m3:og', [NumericRadiusAxis.$, null], 'RadiusMemberPath:n1:oh', [2], 'UseCartesianInterpolation:nn:op', [0, true], 'TrendLineType:ne:on', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness:np:om', [1, 1.5], 'TrendLinePeriod:nr:ol', [1, 7], 'TrendLineZIndex:ns:oo', [1, 1], 'TrendLineBrush:or:oi', [Brush.$, null], 'TrendLineDashArray:os:oj', [DoubleCollection.$], 'TrendLineDashCap:ot:ok', [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.nq = 1000;
            this.by.l0 = 2;
        }
    }
    co() {
        let a = new NumericMarkerManager(0, (b) => this.cs.item(b), (b) => this.cq.m5.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.ou);
        return a;
    }
    cv(a) {
        this.cq.n9(a, this.cs);
    }
    cn() {
        return this.cq.mz(this.cs, this.bs, this.br);
    }
    ct() {
        return this.cq.no(this.cs);
    }
    cu(a, b, c, d) {
        if (this.cq.nl) {
            let e = new GeometryGroup();
            this.cq.m3.lw(e, a, b, c, d);
        }
        else {
        }
    }
    cw() {
        if (this.cq.or != null) {
            this.cq.oq = this.cq.or;
        }
        else {
            this.cq.oq = this.cq.k2;
        }
    }
    cc(a) {
        this.cs.f(a);
    }
    a2(a, b) {
        if (a.d) {
            if (this.cq.ne != 0 && !b) {
                let c = this.cr.g$j;
                c.ac = this.cq.np;
                c._stroke = this.cq.oq;
                c.ad = this.cq.ot;
                c.ai = this.cq.os;
                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.nv + "}" + "</span><br/><span";
        let b = this.e.a0.a$q(this.e);
        if (!stringIsNullOrEmpty(b)) {
            a += " style='color:" + b + "'";
        }
        a += ">" + this.cq.fx + ": </span><span class='ui-priority-primary'>" + "${item." + this.cq.n1 + "}</span></div>";
        return a;
    }
}
PolarBaseView.$t = markType(PolarBaseView, 'PolarBaseView', MarkerSeriesView.$);
//# sourceMappingURL=PolarBase_combined.js.map