/*
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-react-core";
import { PolarAxisInfoCache } from "./PolarAxisInfoCache";
import { SeriesRenderer$2 } from "./SeriesRenderer$2";
import { PolarFrame } from "./PolarFrame";
import { DependencyProperty } from "igniteui-react-core";
import { NumericAngleAxis } from "./NumericAngleAxis";
import { NumericRadiusAxis } from "./NumericRadiusAxis";
import { TrendLineType_$type } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { PenLineCap_$type } from "igniteui-react-core";
import { DoubleCollection } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-react-core";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { PolarAxes } from "./PolarAxes";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { AxisRange } from "./AxisRange";
import { HashPool$2 } from "igniteui-react-core";
import { Clipper } from "igniteui-react-core";
import { OwnedPoint } from "./OwnedPoint";
import { Dictionary$2 } from "igniteui-react-core";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { PolarTrendLineManager } from "./PolarTrendLineManager";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_, isInfinity } from "igniteui-react-core";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { GeometryGroup } from "igniteui-react-core";
import { stringIsNullOrEmpty } from "igniteui-react-core";
/**
 * @hidden
 */
export let PolarBase = /*@__PURE__*/ (() => {
    class PolarBase extends MarkerSeries {
        constructor() {
            super();
            this.nl = null;
            this.ne = null;
            this.nj = null;
            this.pb = null;
            this.pa = null;
            this.nr = null;
            this.nt = null;
            this.nu = null;
            this.no = new PolarFrame();
            this.nq = new PolarFrame();
            this.nn = new PolarFrame();
            this.ni = null;
            this.np = null;
            this.nm = null;
            this.np = new PolarFrame();
            this.nq.x = runOn(this, this.o9);
            this.no.x = runOn(this, this.o9);
            this.nn.x = runOn(this, this.o9);
            this.nr = new SeriesRenderer$2(PolarFrame.$, PolarBaseView.$, 0, runOn(this, this.om), runOn(this, this.oo), runOn(this, this.ca), runOn(this, this.jt), runOn(this, this.ok));
        }
        bf() {
            return new PolarBaseView(this);
        }
        i2(a) {
            super.i2(a);
            this.nk = a;
        }
        h1() {
            super.h1();
            this.ng = null;
            this.nh = null;
        }
        get_c0() {
            return true;
        }
        n0(a) {
            if (!this.hasMarkers) {
                return false;
            }
            let b = this.ng;
            let c = new ScalerParams(1, this.bs.n2, this.l8, b.ca);
            c.c = this.getEffectiveViewport1(this.bi);
            let d = this.nh;
            let e = new ScalerParams(1, this.bs.n2, this.l8, d.ca);
            e.c = this.getEffectiveViewport1(this.bi);
            a.clear();
            this.ma.cc((f) => {
                if (f._visibility == 0) {
                    let g = new SeriesPointOfInterest();
                    let h = f.n;
                    let i = f.o;
                    if (h < this.l8.left || h > this.l8.right || i < this.l8.top || i > this.l8.bottom) {
                        return;
                    }
                    g.b = b.d1(h, c);
                    g.c = d.d1(i, e);
                    g.a = f.content;
                    a.add(g);
                }
            });
            return true;
        }
        ok() {
            if (this.bt.g) {
                this.bt.t();
            }
        }
        ol() {
            this.ni.e(this.nl.w, this.nv, this.nw, this.pb, this.pa, (a, b) => Math.cos(b), (a, b) => Math.sin(b), true);
        }
        get nv() {
            return this.nt;
        }
        set nv(a) {
            if (this.nt != a) {
                let b = this.nv;
                this.nt = a;
                this.raisePropertyChanged("AngleColumn", b, this.nv);
            }
        }
        get nw() {
            return this.nu;
        }
        set nw(a) {
            if (this.nu != a) {
                let b = this.nw;
                this.nu = a;
                this.raisePropertyChanged("RadiusColumn", b, this.nw);
            }
        }
        get o4() {
            return this.c(PolarBase.op);
        }
        set o4(a) {
            this.h(PolarBase.op, a);
        }
        ik() {
            super.ik();
            if (this.nh != null) {
                this.nh.hb(false);
            }
            if (this.ng != null) {
                this.ng.hb(false);
            }
        }
        h6(a, b, c, d) {
            let e = false;
            this.nk.cr.g$e(a, b, c, d);
            if (this.ng != null && !this.ng.cn()) {
                e = true;
            }
            if (this.nh != null && !this.nh.cn()) {
                e = true;
            }
            if (e) {
                this.jl(true);
            }
        }
        j0(a, b) {
            this.jl(false);
        }
        j1(a, b) {
            this.jl(false);
        }
        dw(a, b, c) {
            let d = true;
            if (!super.dw(a, b, c) || !c.l() || b.isEmpty || a.isEmpty || this.ng == null || this.nh == null || this.nv == null || this.nw == null || this.nv.count == 0 || this.nw.count == 0 || this.bz == null || this.bz.count != this.nv.count || this.bz.count != this.nw.count || this.ni == null || this.ng.bh == null || this.nh.bh == null || this.ng.kc == this.ng.kb || this.nh.kc == this.nh.kb) {
                d = false;
            }
            return d;
        }
        jm(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.h3(true, this.bi);
                return;
            }
            this.pb = b;
            this.pa = c;
            this.nj = new PolarAxisInfoCache(this.ng, this.nh, this.bz);
            let e = new SeriesRenderingArguments(this, c, b, a, this.de);
            let f = this.nr.g(e, this.no, this.nn, this.nq, this.nk);
            this.no = f.p1;
            this.nn = f.p2;
            this.nq = f.p3;
        }
        o9(a) {
            let b = this.ni.h(a.x, a.y, this.pb, this.pa, this.nj.e, this.nj.d, this.nj.g, this.nj.f, this.nj.i, this.nj.h);
            return b;
        }
        an(a) {
            if (a != null && a == this.ng && this.nv != null) {
                return new AxisRange(this.nv.minimum, this.nv.maximum);
            }
            if (a != null && a == this.nh && this.nw != null) {
                return new AxisRange(this.nw.minimum, this.nw.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.ng == null || this.nv == null || this.nh == null || this.nw == null) {
                return false;
            }
            if (d < 0 || d > this.nv.count - 1 || d > this.nw.count - 1) {
                return false;
            }
            let e = this.ng.getScaledAngle(this.nv.item(d));
            let f = this.nh.lx(this.nw.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.ng, this.nh];
        }
        fs(a, b) {
            let c = this.g2(b);
            if (c == PolarBase.$$p[1]) {
                return this.ft(a, b, this.n9);
            }
            if (c == PolarBase.$$p[5]) {
                return this.ft(a, b, this.of);
            }
            return super.fs(a, b);
        }
        i7(a, b, c, d) {
            super.i7(a, b, c, d);
            if (this.nk.cr.g$b(a, b, c, d)) {
                this.jl(false);
                this.it();
            }
            switch (b) {
                case "FastItemsSource":
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.nv);
                        c.deregisterColumn(this.nw);
                        this.nv = null;
                        this.nw = null;
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.nv = this.bw(this.n9);
                        this.nw = this.bw(this.of);
                    }
                    if ((this.nh != null && !this.nh.cn()) || (this.ng != null && !this.ng.cn())) {
                        this.jl(false);
                    }
                    break;
                case PolarBase.$$p[0]:
                    if (this.ng != null && this.nh != null) {
                        this.ni = new PolarAxes(this.nh, this.ng);
                    }
                    if (c != null) {
                        c.bx(this);
                    }
                    if (d != null) {
                        d.ck(this);
                    }
                    if (this.ng != null && !this.ng.cn()) {
                        this.jl(false);
                    }
                    else if (c != null && d == null) {
                        this.h3(true, this.bi);
                    }
                    break;
                case PolarBase.$$p[4]:
                    if (this.ng != null && this.nh != null) {
                        this.ni = new PolarAxes(this.nh, this.ng);
                    }
                    if (c != null) {
                        c.bx(this);
                    }
                    if (d != null) {
                        d.ck(this);
                    }
                    if (this.nh != null && !this.nh.cn()) {
                        this.jl(false);
                    }
                    else if (c != null && d == null) {
                        this.h3(true, this.bi);
                    }
                    if (this.ng != null && !this.ng.cn()) {
                        this.ng.g7();
                    }
                    break;
                case PolarBase.$$p[1]:
                    if (this.bz != null) {
                        this.bz.deregisterColumn(this.nv);
                        this.nv = this.bw(this.n9);
                    }
                    break;
                case "AngleColumn":
                    this.nk.cr.g$i();
                    if (this.ng != null && !this.ng.cn()) {
                        this.jl(false);
                    }
                    break;
                case PolarBase.$$p[5]:
                    if (this.bz != null) {
                        this.bz.deregisterColumn(this.nw);
                        this.nw = this.bw(this.of);
                    }
                    break;
                case "RadiusColumn":
                    this.nk.cr.g$i();
                    if (this.nh != null && !this.nh.cn()) {
                        this.jl(false);
                    }
                    break;
                case PolarBase.$$p[6]:
                    this.jl(false);
                    this.it();
                    break;
                case PolarBase.$$p[3]:
                    this.jl(false);
                    this.it();
                    break;
                case "TransitionProgress":
                    this.nj = new PolarAxisInfoCache(this.ng, this.nh, this.bz);
                    this.pb = this.bi.bs;
                    this.pa = this.bi.br;
                    this.nq.v = this.n1;
                    this.nq.c(this.ez, this.no, this.nn);
                    if (this.cc(this.bi)) {
                        return;
                    }
                    if (this.ez == 1) {
                        this.oo(this.nn, this.nk);
                    }
                    else {
                        this.oo(this.nq, this.nk);
                    }
                    if (this.bs != null) {
                        this.bs.ko(this);
                    }
                    break;
                case "TrendLineBrush":
                    this.jw();
                    break;
                case PolarBase.$$p[2]:
                    this.jl(false);
                    this.it();
                    break;
                case "TrendLineType":
                    this.it();
                    break;
            }
        }
        ny(a) {
            if (typeCast(NumericRadiusAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        nx(a) {
            if (typeCast(NumericAngleAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        h3(a, b) {
            super.h3(a, b);
            let c = b;
            if (a) {
                c.cs.clear();
            }
            c.cr.g$d();
        }
        nf(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;
        }
        oj(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.nv.item(f), y: this.nw.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;
                    })()));
                }
            }
        }
        om(a, b) {
            let c = b.bs;
            let d = b.br;
            a.j.clear();
            a.n.clear();
            let e = Math.min(this.nv != null ? this.nv.count : 0, this.nw != null ? this.nw.count : 0);
            if (e < 1) {
                return;
            }
            this.nj = new PolarAxisInfoCache(this.ng, this.nh, this.bz);
            this.nl = a;
            this.pa = d;
            this.pb = c;
            b.cp.l(a.j, this.n4, c, d, this.eu);
            if (e <= this.n4) {
                this.oj(a, e, c, d);
            }
            let f = this.nf(d, a.n);
            let g = Math.min(this.ng.kc, this.ng.kb);
            let h = Math.max(this.ng.kb, this.ng.kc);
            b.cr.i = this.n1;
            b.cr.h = 0;
            b.cr.k = this.nh.lr;
            b.cr.j = this.nh.lq;
            b.cr.l = (i, j) => this.ni.c(i, j, c, d, Math.cos);
            b.cr.m = (i, j) => this.ni.d(i, j, c, d, Math.sin);
            let i = new List$1(Number_$type, 0);
            for (let j = 0; j < this.nv.count; j++) {
                if (this.nv.item(j) >= g && this.nv.item(j) <= h) {
                    i.add(this.nv.item(j));
                }
            }
            let k = this.nw;
            if (i.count != this.nv.count) {
                k = new List$1(Number_$type, 0);
                for (let l = 0; l < this.nv.count; l++) {
                    if (this.nv.item(l) >= g && this.nv.item(l) <= h) {
                        k.add(this.nw.item(l));
                    }
                }
            }
            b.cr.n(a.n, this.ns, i, k, this.n5, runOn(this.ng, this.ng.getScaledAngle), runOn(this.nh, this.nh.lx), ((() => {
                let $ret = new TrendResolutionParams();
                $ret.b = this.eu;
                $ret.f = d;
                $ret.g = c;
                return $ret;
            })()), f, g, h);
        }
        oo(a, b) {
            let c = b.bs;
            let d = b.br;
            let e = this.getEffectiveViewport1(b);
            let f = this.l0(b);
            this.nj = new PolarAxisInfoCache(this.ng, this.nh, this.bz);
            b.cp.j(a.j, this.mf);
            b.cj();
            let g = this.nf(d, b.cr.g$j.ak);
            b.cr.g$h(a.n, g);
            this.oi(d, c, e, f, b);
        }
        oi(a, b, c, d, e) {
            e.cu(a, b, c, d);
        }
        jw() {
            super.jw();
            if (this.fh < 0) {
                return;
            }
            this.nk.cw();
        }
        jn(a, b) {
            super.jn(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.np = new PolarFrame();
                this.om(this.np, c);
            }
            this.df = false;
            this.oo(this.np, c);
            this.dl = false;
        }
        jk(a, b, c, d, e) {
            super.jk(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.nm == null) {
                this.nm = new PolarFrame();
            }
            this.om(this.nm, g);
            this.oo(this.nm, g);
        }
        on(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);
            }
        }
        nd(a, b, c) {
            this.ol();
            return this.nl.w.toArray();
        }
        n2(a) {
            let b = new List$1(Number_$type, 0);
            let c = this.bz;
            for (let d of fromEnum(this.nk.cs.c)) {
                b.add(c.indexOf(d));
            }
            return b;
        }
        o8(a) {
            return { $type: Point_$type, x: this.nv.item(a), y: this.nw.item(a) };
        }
        ic(a) {
            super.ic(a);
            this.a2.exportTrendlineData(this, a, this.nk.cr.g$j);
        }
    }
    PolarBase.$t = /*@__PURE__*/ markType(PolarBase, 'PolarBase', MarkerSeries.$);
    PolarBase.op = /*@__PURE__*/ DependencyProperty.i("ActualTrendLineBrush", Brush.$, PolarBase.$, /*@__PURE__*/ new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
    PolarBase.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, PolarBase, 'raisePropertyChanged', ['AngleAxis:ng:oq', [NumericAngleAxis.$, null], 'AngleMemberPath:n9:or', [2], 'ClipSeriesToBounds:nz:os', [0, false], 'MaximumMarkers:n4:ot', [1, 400], 'RadiusAxis:nh:ou', [NumericRadiusAxis.$, null], 'RadiusMemberPath:of:ov', [2], 'UseCartesianInterpolation:n1:o3', [0, true], 'TrendLineType:ns:o1', [TrendLineType_$type, /*@__PURE__*/ enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness:n3:o0', [1, 1.5], 'TrendLinePeriod:n5:oz', [1, 7], 'TrendLineZIndex:n6:o2', [1, 1], 'TrendLineBrush:o5:ow', [Brush.$, null], 'TrendLineDashArray:o6:ox', [DoubleCollection.$], 'TrendLineDashCap:o7:oy', [PenLineCap_$type, /*@__PURE__*/ enumGetBox(PenLineCap_$type, 0)]]);
    return PolarBase;
})();
/**
 * @hidden
 */
export let PolarBaseView = /*@__PURE__*/ (() => {
    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.n4 = 1000;
                this.by.mb = 2;
            }
        }
        co() {
            let a = new NumericMarkerManager(0, (b) => this.cs.item(b), (b) => this.cq.nj.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.o8);
            return a;
        }
        cv(a) {
            this.cq.on(a, this.cs);
        }
        cn() {
            return this.cq.nd(this.cs, this.bs, this.br);
        }
        ct() {
            return this.cq.n2(this.cs);
        }
        cu(a, b, c, d) {
            if (this.cq.nz) {
                let e = new GeometryGroup();
                this.cq.nh.l5(e, a, b, c, d);
            }
            else {
            }
        }
        cw() {
            if (this.cq.o5 != null) {
                this.cq.o4 = this.cq.o5;
            }
            else {
                this.cq.o4 = this.cq.lb;
            }
        }
        cc(a) {
            this.cs.f(a);
        }
        a2(a, b) {
            if (a.d) {
                if (this.cq.ns != 0 && !b) {
                    let c = this.cr.g$j;
                    c.ac = this.cq.n3;
                    c._stroke = this.cq.o4;
                    c.ad = this.cq.o7;
                    c.ai = this.cq.o6;
                    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.n9 + "}" + "</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.of + "}</span></div>";
            return a;
        }
    }
    PolarBaseView.$t = /*@__PURE__*/ markType(PolarBaseView, 'PolarBaseView', MarkerSeriesView.$);
    return PolarBaseView;
})();
//# sourceMappingURL=PolarBase_combined.js.map
