/*
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, runOn, Number_$type, enumGetBox, typeCast, Point_$type, fromEnum, markType, markDep } from "igniteui-angular-core";
import { PolarAxisInfoCache } from "./PolarAxisInfoCache";
import { SeriesRenderer$2 } from "./SeriesRenderer$2";
import { PolarFrame } from "./PolarFrame";
import { DependencyProperty } from "igniteui-angular-core";
import { NumericAngleAxis } from "./NumericAngleAxis";
import { NumericRadiusAxis } from "./NumericRadiusAxis";
import { TrendLineType_$type } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { PenLineCap_$type } from "igniteui-angular-core";
import { DoubleCollection } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-angular-core";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { PolarAxes } from "./PolarAxes";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { AxisRange } from "./AxisRange";
import { HashPool$2 } from "igniteui-angular-core";
import { Clipper } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { OwnedPoint } from "./OwnedPoint";
import { PolarTrendLineManager } from "./PolarTrendLineManager";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, isInfinity } from "igniteui-angular-core";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { GeometryGroup } from "igniteui-angular-core";
import { stringIsNullOrEmpty } from "igniteui-angular-core";
/**
 * @hidden
 */
export class PolarBase extends MarkerSeries {
    constructor() {
        super();
        this.m8 = null;
        this.m1 = null;
        this.m6 = null;
        this.oy = null;
        this.ox = null;
        this.ne = null;
        this.ng = null;
        this.nh = null;
        this.nb = new PolarFrame();
        this.nd = new PolarFrame();
        this.na = new PolarFrame();
        this.m5 = null;
        this.nc = null;
        this.m9 = null;
        this.nc = new PolarFrame();
        this.nd.x = runOn(this, this.ow);
        this.nb.x = runOn(this, this.ow);
        this.na.x = runOn(this, this.ow);
        this.ne = new SeriesRenderer$2(PolarFrame.$, PolarBaseView.$, 0, runOn(this, this.n9), runOn(this, this.ob), runOn(this, this.ca), runOn(this, this.jl), runOn(this, this.n7));
    }
    bf() {
        return new PolarBaseView(this);
    }
    iu(a) {
        super.iu(a);
        this.m7 = a;
    }
    ht() {
        super.ht();
        this.m3 = null;
        this.m4 = null;
    }
    get_c0() {
        return true;
    }
    nn(a) {
        if (!this.hasMarkers) {
            return false;
        }
        let b = this.m3;
        let c = new ScalerParams(1, this.bs.mq, this.ly, b.b8);
        c.c = this.getEffectiveViewport1(this.bi);
        let d = this.m4;
        let e = new ScalerParams(1, this.bs.mq, this.ly, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.l0.cc((f) => {
            if (f._visibility == 0) {
                let g = new SeriesPointOfInterest();
                let h = f.n;
                let i = f.o;
                if (h < this.ly.left || h > this.ly.right || i < this.ly.top || i > this.ly.bottom) {
                    return;
                }
                g.b = b.dz(h, c);
                g.c = d.dz(i, e);
                g.a = f.content;
                a.add(g);
            }
        });
        return true;
    }
    n7() {
        if (this.bt.g) {
            this.bt.t();
        }
    }
    n8() {
        this.m5.e(this.m8.w, this.ni, this.nj, this.oy, this.ox, (a, b) => Math.cos(b), (a, b) => Math.sin(b), true);
    }
    get ni() {
        return this.ng;
    }
    set ni(a) {
        if (this.ng != a) {
            let b = this.ni;
            this.ng = a;
            this.raisePropertyChanged("AngleColumn", b, this.ni);
        }
    }
    get nj() {
        return this.nh;
    }
    set nj(a) {
        if (this.nh != a) {
            let b = this.nj;
            this.nh = a;
            this.raisePropertyChanged("RadiusColumn", b, this.nj);
        }
    }
    get or() {
        return this.c(PolarBase.oc);
    }
    set or(a) {
        this.h(PolarBase.oc, a);
    }
    ib() {
        super.ib();
        if (this.m4 != null) {
            this.m4.g6(false);
        }
        if (this.m3 != null) {
            this.m3.g6(false);
        }
    }
    hy(a, b, c, d) {
        let e = false;
        this.m7.cr.g$e(a, b, c, d);
        if (this.m3 != null && !this.m3.cl()) {
            e = true;
        }
        if (this.m4 != null && !this.m4.cl()) {
            e = true;
        }
        if (e) {
            this.jd(true);
        }
    }
    js(a, b) {
        this.jd(false);
    }
    jt(a, b) {
        this.jd(false);
    }
    dw(a, b, c) {
        let d = true;
        if (!super.dw(a, b, c) || !c.l() || b.isEmpty || a.isEmpty || this.m3 == null || this.m4 == null || this.ni == null || this.nj == null || this.ni.count == 0 || this.nj.count == 0 || this.bz == null || this.bz.count != this.ni.count || this.bz.count != this.nj.count || this.m5 == null || this.m3.bf == null || this.m4.bf == null || this.m3.j4 == this.m3.j3 || this.m4.j4 == this.m4.j3) {
            d = false;
        }
        return d;
    }
    je(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.oy = b;
        this.ox = c;
        this.m6 = new PolarAxisInfoCache(this.m3, this.m4, this.bz);
        let e = new SeriesRenderingArguments(this, c, b, a, this.de);
        let f = this.ne.g(e, this.nb, this.na, this.nd, this.m7);
        this.nb = f.p1;
        this.na = f.p2;
        this.nd = f.p3;
    }
    ow(a) {
        let b = this.m5.h(a.x, a.y, this.oy, this.ox, this.m6.e, this.m6.d, this.m6.g, this.m6.f, this.m6.i, this.m6.h);
        return b;
    }
    an(a) {
        if (a != null && a == this.m3 && this.ni != null) {
            return new AxisRange(this.ni.minimum, this.ni.maximum);
        }
        if (a != null && a == this.m4 && this.nj != null) {
            return new AxisRange(this.nj.minimum, this.nj.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.m3 == null || this.ni == null || this.m4 == null || this.nj == null) {
            return false;
        }
        if (d < 0 || d > this.ni.count - 1 || d > this.nj.count - 1) {
            return false;
        }
        let e = this.m3.getScaledAngle(this.ni.item(d));
        let f = this.m4.lp(this.nj.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.m3, this.m4];
    }
    fs(a, b) {
        let c = this.gu(b);
        if (c == PolarBase.$$p[1]) {
            return this.ft(a, b, this.nw);
        }
        if (c == PolarBase.$$p[5]) {
            return this.ft(a, b, this.n2);
        }
        return super.fs(a, b);
    }
    iz(a, b, c, d) {
        super.iz(a, b, c, d);
        if (this.m7.cr.g$b(a, b, c, d)) {
            this.jd(false);
            this.ik();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.ni);
                    c.deregisterColumn(this.nj);
                    this.ni = null;
                    this.nj = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.ni = this.bw(this.nw);
                    this.nj = this.bw(this.n2);
                }
                if ((this.m4 != null && !this.m4.cl()) || (this.m3 != null && !this.m3.cl())) {
                    this.jd(false);
                }
                break;
            case PolarBase.$$p[0]:
                if (this.m3 != null && this.m4 != null) {
                    this.m5 = new PolarAxes(this.m4, this.m3);
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ci(this);
                }
                if (this.m3 != null && !this.m3.cl()) {
                    this.jd(false);
                }
                else if (c != null && d == null) {
                    this.hv(true, this.bi);
                }
                break;
            case PolarBase.$$p[4]:
                if (this.m3 != null && this.m4 != null) {
                    this.m5 = new PolarAxes(this.m4, this.m3);
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ci(this);
                }
                if (this.m4 != null && !this.m4.cl()) {
                    this.jd(false);
                }
                else if (c != null && d == null) {
                    this.hv(true, this.bi);
                }
                if (this.m3 != null && !this.m3.cl()) {
                    this.m3.g2();
                }
                break;
            case PolarBase.$$p[1]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.ni);
                    this.ni = this.bw(this.nw);
                }
                break;
            case "AngleColumn":
                this.m7.cr.g$i();
                if (this.m3 != null && !this.m3.cl()) {
                    this.jd(false);
                }
                break;
            case PolarBase.$$p[5]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.nj);
                    this.nj = this.bw(this.n2);
                }
                break;
            case "RadiusColumn":
                this.m7.cr.g$i();
                if (this.m4 != null && !this.m4.cl()) {
                    this.jd(false);
                }
                break;
            case PolarBase.$$p[6]:
                this.jd(false);
                this.ik();
                break;
            case PolarBase.$$p[3]:
                this.jd(false);
                this.ik();
                break;
            case "TransitionProgress":
                this.m6 = new PolarAxisInfoCache(this.m3, this.m4, this.bz);
                this.oy = this.bi.bs;
                this.ox = this.bi.br;
                this.nd.v = this.no;
                this.nd.c(this.ez, this.nb, this.na);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.ez == 1) {
                    this.ob(this.na, this.m7);
                }
                else {
                    this.ob(this.nd, this.m7);
                }
                if (this.bs != null) {
                    this.bs.jj(this);
                }
                break;
            case "TrendLineBrush":
                this.jo();
                break;
            case PolarBase.$$p[2]:
                this.jd(false);
                this.ik();
                break;
            case "TrendLineType":
                this.ik();
                break;
        }
    }
    nl(a) {
        if (typeCast(NumericRadiusAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    nk(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();
    }
    m2(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;
    }
    n6(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.ni.item(f), y: this.nj.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;
                })()));
            }
        }
    }
    n9(a, b) {
        let c = b.bs;
        let d = b.br;
        a.j.clear();
        a.n.clear();
        let e = Math.min(this.ni != null ? this.ni.count : 0, this.nj != null ? this.nj.count : 0);
        if (e < 1) {
            return;
        }
        this.m6 = new PolarAxisInfoCache(this.m3, this.m4, this.bz);
        this.m8 = a;
        this.ox = d;
        this.oy = c;
        b.cp.l(a.j, this.nr, c, d, this.eu);
        if (e <= this.nr) {
            this.n6(a, e, c, d);
        }
        let f = this.m2(d, a.n);
        let g = Math.min(this.m3.j4, this.m3.j3);
        let h = Math.max(this.m3.j3, this.m3.j4);
        b.cr.q = this.no;
        b.cr.p = 0;
        b.cr.s = this.m4.lj;
        b.cr.r = this.m4.li;
        b.cr.t = (i, j) => this.m5.c(i, j, c, d, Math.cos);
        b.cr.u = (i, j) => this.m5.d(i, j, c, d, Math.sin);
        let i = new List$1(Number_$type, 0);
        for (let j = 0; j < this.ni.count; j++) {
            if (this.ni.item(j) >= g && this.ni.item(j) <= h) {
                i.add(this.ni.item(j));
            }
        }
        let k = this.nj;
        if (i.count != this.ni.count) {
            k = new List$1(Number_$type, 0);
            for (let l = 0; l < this.ni.count; l++) {
                if (this.ni.item(l) >= g && this.ni.item(l) <= h) {
                    k.add(this.nj.item(l));
                }
            }
        }
        b.cr.v(a.n, this.nf, i, k, this.ns, runOn(this.m3, this.m3.getScaledAngle), runOn(this.m4, this.m4.lp), ((() => {
            let $ret = new TrendResolutionParams();
            $ret.b = this.eu;
            $ret.f = d;
            $ret.g = c;
            return $ret;
        })()), f, g, h);
    }
    ob(a, b) {
        let c = b.bs;
        let d = b.br;
        let e = this.getEffectiveViewport1(b);
        let f = this.lq(b);
        this.m6 = new PolarAxisInfoCache(this.m3, this.m4, this.bz);
        b.cp.j(a.j, this.l5);
        b.cj();
        let g = this.m2(d, b.cr.g$j.ak);
        b.cr.g$h(a.n, g);
        this.n5(d, c, e, f, b);
    }
    n5(a, b, c, d, e) {
        e.cu(a, b, c, d);
    }
    jo() {
        super.jo();
        if (this.fh < 0) {
            return;
        }
        this.m7.cw();
    }
    jf(a, b) {
        super.jf(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.nc = new PolarFrame();
            this.n9(this.nc, c);
        }
        this.df = false;
        this.ob(this.nc, c);
        this.dl = false;
    }
    jc(a, b, c, d, e) {
        super.jc(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.m9 == null) {
            this.m9 = new PolarFrame();
        }
        this.n9(this.m9, g);
        this.ob(this.m9, g);
    }
    oa(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);
        }
    }
    m0(a, b, c) {
        this.n8();
        return this.m8.w.toArray();
    }
    np(a) {
        let b = new List$1(Number_$type, 0);
        let c = this.bz;
        for (let d of fromEnum(this.m7.cs.c)) {
            b.add(c.indexOf(d));
        }
        return b;
    }
    ov(a) {
        return { $type: Point_$type, x: this.ni.item(a), y: this.nj.item(a) };
    }
    h4(a) {
        super.h4(a);
        this.a2.exportTrendlineData(this, a, this.m7.cr.g$j);
    }
}
PolarBase.$t = markType(PolarBase, 'PolarBase', MarkerSeries.$);
PolarBase.oc = DependencyProperty.i("ActualTrendLineBrush", Brush.$, PolarBase.$, new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
PolarBase.$$p = markDep(DependencyProperty, PropertyMetadata, PolarBase, 'raisePropertyChanged', ['AngleAxis:m3:od', [NumericAngleAxis.$, null], 'AngleMemberPath:nw:oe', [2], 'ClipSeriesToBounds:nm:of', [0, false], 'MaximumMarkers:nr:og', [1, 400], 'RadiusAxis:m4:oh', [NumericRadiusAxis.$, null], 'RadiusMemberPath:n2:oi', [2], 'UseCartesianInterpolation:no:oq', [0, true], 'TrendLineType:nf:oo', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness:nq:on', [1, 1.5], 'TrendLinePeriod:ns:om', [1, 7], 'TrendLineZIndex:nt:op', [1, 1], 'TrendLineBrush:os:oj', [Brush.$, null], 'TrendLineDashArray:ot:ok', [DoubleCollection.$], 'TrendLineDashCap:ou:ol', [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.nr = 1000;
            this.by.l1 = 2;
        }
    }
    co() {
        let a = new NumericMarkerManager(0, (b) => this.cs.item(b), (b) => this.cq.m6.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.ov);
        return a;
    }
    cv(a) {
        this.cq.oa(a, this.cs);
    }
    cn() {
        return this.cq.m0(this.cs, this.bs, this.br);
    }
    ct() {
        return this.cq.np(this.cs);
    }
    cu(a, b, c, d) {
        if (this.cq.nm) {
            let e = new GeometryGroup();
            this.cq.m4.lx(e, a, b, c, d);
        }
        else {
        }
    }
    cw() {
        if (this.cq.os != null) {
            this.cq.or = this.cq.os;
        }
        else {
            this.cq.or = this.cq.k3;
        }
    }
    cc(a) {
        this.cs.f(a);
    }
    a2(a, b) {
        if (a.d) {
            if (this.cq.nf != 0 && !b) {
                let c = this.cr.g$j;
                c.ac = this.cq.nq;
                c._stroke = this.cq.or;
                c.ad = this.cq.ou;
                c.ai = this.cq.ot;
                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.nw + "}" + "</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.n2 + "}</span></div>";
        return a;
    }
}
PolarBaseView.$t = markType(PolarBaseView, 'PolarBaseView', MarkerSeriesView.$);
//# sourceMappingURL=PolarBase_combined.js.map