/*
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, delegateCombine, Number_$type, enumGetBox, Point_$type, typeCast, 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 { ScatterItemSearchMode_$type } from "./ScatterItemSearchMode";
import { HighlightingInfo } 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 { SeriesLayerPropertyOverlay } from "./SeriesLayerPropertyOverlay";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { AxisRange } from "./AxisRange";
import { Dictionary$2 } from "igniteui-react-core";
import { OwnedPoint } from "./OwnedPoint";
import { GeometryUtil } from "igniteui-react-core";
import { DataContext } from "igniteui-react-core";
import { HashPool$2 } from "igniteui-react-core";
import { Clipper } from "igniteui-react-core";
import { PolarTrendLineManager } from "./PolarTrendLineManager";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { AssigningPolarStyleEventArgs } from "./AssigningPolarStyleEventArgs";
import { AssigningPolarMarkerStyleEventArgs } from "./AssigningPolarMarkerStyleEventArgs";
import { SeriesRenderManager } from "./SeriesRenderManager";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
import { Defaults } from "./Defaults";
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 {
        cd() {
            return new PolarBaseView(this);
        }
        o2(a) {
            super.o2(a);
            this.vs = a;
        }
        nh() {
            super.nh();
            this.vo = null;
            this.vp = null;
        }
        get_e3() {
            return true;
        }
        dt(a, b, c, d) {
            if (!this.hasMarkers) {
                return false;
            }
            let e = this.vo;
            let f = new ScalerParams(1, this.cv.tr, this.ty, e.ch);
            f.c = this.getEffectiveViewport1(this.cg);
            let g = this.vp;
            let h = new ScalerParams(1, this.cv.tr, this.ty, g.ch);
            h.c = this.getEffectiveViewport1(this.cg);
            a.clear();
            this.ub.ci((i) => {
                if (i._visibility == 0) {
                    let j = new SeriesPointOfInterest();
                    let k = i.n;
                    let l = i.o;
                    if (k < this.ty.left || k > this.ty.right || l < this.ty.top || l > this.ty.bottom) {
                        return;
                    }
                    let m;
                    let n;
                    let o = this.vq.f(k, l, this.cg.by, this.cg.bx, m, n);
                    m = o.p4;
                    n = o.p5;
                    j.b = m;
                    j.c = n;
                    j.a = i.content;
                    a.add(j);
                }
            });
            return true;
        }
        constructor() {
            super();
            this.vt = null;
            this.vk = null;
            this.vr = null;
            this.y9 = null;
            this.y8 = null;
            this.v5 = null;
            this.wc = null;
            this.wd = null;
            this.vx = new PolarFrame();
            this.vz = new PolarFrame();
            this.vv = new PolarFrame();
            this.vq = null;
            this.wv = null;
            this.v1 = 1;
            this.wh = false;
            this.wg = false;
            this.wa = null;
            this.wb = null;
            this.assigningPolarStyle = null;
            this.assigningPolarMarkerStyle = null;
            this.v0 = null;
            this.vy = null;
            this.vu = null;
            this.v0 = new PolarSeriesRenderManager();
            this.v2 = this.v3();
            this.vy = new PolarFrame();
            this.vz.x = runOn(this, this.y7);
            this.vx.x = runOn(this, this.y7);
            this.vv.x = runOn(this, this.y7);
            this.v5 = new SeriesRenderer$2(PolarFrame.$, PolarBaseView.$, 0, runOn(this, this.x8), runOn(this, this.yc), runOn(this, this.dk), runOn(this, this.p5), runOn(this, this.x1));
        }
        x1() {
            if (this.cw.g) {
                this.cw.t();
            }
        }
        x3() {
            this.vq.e(this.vt.w, this.we, this.wf, this.y9, this.y8, (a, b) => Math.cos(b), (a, b) => Math.sin(b), true);
        }
        fo() {
            return this.highlightedItemsSource != null || (this.xj != null && this.xh != null);
        }
        wt() {
            return false;
        }
        g1() {
            let a = super.g1();
            {
                let b = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.ad = "AngleMemberPath";
                    $ret.p = true;
                    $ret.y = "HighlightedAngleMemberPath";
                    $ret.q = true;
                    return $ret;
                })());
                b.valueResolving = delegateCombine(b.valueResolving, runOn(this, this.x4));
                a.add(b);
            }
            {
                let c = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.ad = "RadiusMemberPath";
                    $ret.p = true;
                    $ret.y = "HighlightedRadiusMemberPath";
                    $ret.q = true;
                    return $ret;
                })());
                c.valueResolving = delegateCombine(c.valueResolving, runOn(this, this.x5));
                a.add(c);
            }
            if (this.wt()) {
                let d = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.r = true;
                    $ret.ad = "DashArray";
                    $ret.p = true;
                    $ret.x = ((() => {
                        let $ret = new DoubleCollection();
                        $ret.add(5);
                        $ret.add(5);
                        return $ret;
                    })());
                    $ret.q = true;
                    return $ret;
                })());
                a.add(d);
            }
            if (!this.wt()) {
                let e = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.r = true;
                    $ret.ad = "Brush";
                    $ret.p = true;
                    $ret.y = "ActualBrush";
                    $ret.q = true;
                    return $ret;
                })());
                e.valueResolving = delegateCombine(e.valueResolving, runOn(this, this.pz));
                a.add(e);
            }
            if (!this.wt()) {
                let f = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.r = true;
                    $ret.ad = "Outline";
                    $ret.p = true;
                    $ret.y = "ActualOutline";
                    $ret.q = true;
                    return $ret;
                })());
                f.valueResolving = delegateCombine(f.valueResolving, runOn(this, this.pz));
                a.add(f);
            }
            return a;
        }
        x5(a, b) {
            if (this.xj != null) {
                b.value = this.xj;
                return;
            }
            b.value = this.xw;
        }
        x4(a, b) {
            if (this.xh != null) {
                b.value = this.xh;
                return;
            }
            b.value = this.xe;
        }
        get we() {
            return this.wc;
        }
        set we(a) {
            if (this.wc != a) {
                let b = this.we;
                this.wc = a;
                this.raisePropertyChanged("AngleColumn", b, this.we);
            }
        }
        get wf() {
            return this.wd;
        }
        set wf(a) {
            if (this.wd != a) {
                let b = this.wf;
                this.wd = a;
                this.raisePropertyChanged("RadiusColumn", b, this.wf);
            }
        }
        get y2() {
            return this.c(PolarBase.yd);
        }
        set y2(a) {
            this.h(PolarBase.yd, a);
        }
        vw() {
            let a = this.vv;
            if (this.dk()) {
                if (this.cw.g) {
                    this.cw.t();
                }
                a = this.vz;
            }
            return a;
        }
        oc() {
            super.oc();
            if (this.vp != null) {
                this.vp.h8(false);
            }
            if (this.vo != null) {
                this.vo.h8(false);
            }
        }
        np(a, b, c, d) {
            let e = false;
            this.vs.cy.g$e(a, b, c, d);
            if (this.vo != null && !this.vo.c1()) {
                e = true;
            }
            if (this.vp != null && !this.vp.c1()) {
                e = true;
            }
            if (e) {
                this.pr(true);
            }
        }
        qo(a, b) {
            this.pr(false);
        }
        qp(a, b) {
            this.pr(false);
        }
        gm(a, b, c) {
            let d = true;
            if (!super.gm(a, b, c) || !c.o() || b.isEmpty || a.isEmpty || this.vo == null || this.vp == null || this.we == null || this.wf == null || this.we.count == 0 || this.wf.count == 0 || this.c7 == null || this.c7.count != this.we.count || this.c7.count != this.wf.count || this.vq == null || this.vo.bi == null || this.vp.bi == null || this.vo.lx == this.vo.lw || this.vp.lx == this.vp.lw) {
                d = false;
            }
            return d;
        }
        ps(a) {
            super.ps(a);
            let b;
            let c;
            let d = this.getViewInfo(c, b);
            c = d.p0;
            b = d.p1;
            if (!this.gm(c, b, this.cg)) {
                this.nk(true, this.cg);
                return;
            }
            this.y9 = b;
            this.y8 = c;
            this.vr = new PolarAxisInfoCache(this.vo, this.vp, this.c7);
            let e = new SeriesRenderingArguments(this, c, b, a, this.f1);
            let f = this.v5.g(e, this.vx, this.vv, this.vz, this.vs);
            this.vx = f.p1;
            this.vv = f.p2;
            this.vz = f.p3;
        }
        y7(a) {
            let b = this.vq.h(a.x, a.y, this.y9, this.y8, this.vr.e, this.vr.d, this.vr.g, this.vr.f, this.vr.i, this.vr.h);
            return b;
        }
        aq(a) {
            if (a != null && a == this.vo && this.we != null) {
                return new AxisRange(this.we.minimum, this.we.maximum);
            }
            if (a != null && a == this.vp && this.wf != null) {
                return new AxisRange(this.wf.minimum, this.wf.maximum);
            }
            return null;
        }
        fp(a) {
            let b = this.cg.by;
            b = b.copy();
            let c = this.cg.bx;
            let d = !b.isEmpty && !c.isEmpty && this.c7 != null ? this.c7.indexOf(a) : -1;
            if (this.vo == null || this.we == null || this.vp == null || this.wf == null) {
                return false;
            }
            if (d < 0 || d > this.we.count - 1 || d > this.wf.count - 1) {
                return false;
            }
            let e = this.vo.getScaledAngle(this.we.item(d));
            let f = this.vp.nu(this.wf.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.co != null) {
                this.co.au(this.cv, b, true);
            }
            return d >= 0;
        }
        js(a) {
            let b = this.i9(a);
            if (this.c7 != null && b >= 0 && b < this.c7.count) {
                return this.c7.item(b);
            }
            return null;
        }
        i9(a) {
            let b = truncate(Math.round(this.hw(a)));
            return b;
        }
        hw(a) {
            switch (this.v2) {
                case 1: return this.wz(a);
                case 3: return this.w0(a);
                case 2: return this.wx(a);
                case 4: return this.wy(a);
            }
            return -1;
        }
        wy(a) {
            return this.w1(a, false);
        }
        wx(a) {
            let b = this.te(a);
            let c = b.x;
            let d = b.y;
            if (this.c7 == null || this.vo == null || this.vp == null || this.we == null || this.wf == null) {
                return -1;
            }
            if (this.c7.count > this.w3) {
                return -1;
            }
            if (!this.wl()) {
                return -1;
            }
            let e = this.wv;
            let f = 1.7976931348623157E+308;
            let g = -1;
            for (let h = 0; h < this.we.count; h++) {
                let i = e._inner[h].x;
                let j = e._inner[h].y;
                let k = (c - i) * (c - i) + (d - j) * (d - j);
                if (k < f) {
                    f = k;
                    g = h;
                }
            }
            return g;
        }
        wl() {
            let a = this.vv;
            if (this.dk()) {
                a = this.vz;
            }
            if (a == null || a.w.count == 0) {
                return false;
            }
            this.wv = a.w;
            return true;
        }
        w1(a, b) {
            if (!this.wo) {
                return -1;
            }
            let c = { $type: Point_$type, x: 0, y: 0 };
            let d = true;
            let e = this.vv;
            if (this.dk()) {
                e = this.vz;
            }
            if (e == null) {
                return -1;
            }
            if (e.m == null) {
                return -1;
            }
            if (this.c7 == null || this.c7.count > this.w3) {
                return -1;
            }
            if (!this.wl()) {
                return -1;
            }
            let f = this.wv;
            let g = this.te(a);
            let h = 1.7976931348623157E+308;
            let i = -1;
            for (let j = 0; j < f.count; j++) {
                let k = f._inner[j];
                if (j > 0) {
                    if (isNaN_(k.x) || isNaN_(k.y) || isNaN_(c.x) || isNaN_(c.y)) {
                        c = k;
                        continue;
                    }
                    if (!b || e.j.containsKey(this.c7.item(j)) || e.j.containsKey(this.c7.item(j - 1))) {
                        let l = GeometryUtil.d(g, c, k);
                        if (l < h) {
                            h = l;
                            i = j;
                        }
                    }
                }
                c = k;
            }
            if (i >= 0) {
                let m = f._inner[i];
                let n = f._inner[i - 1];
                if (!b || (e.j.containsKey(this.c7.item(i)) && e.j.containsKey(this.c7.item(i - 1)))) {
                    let o = GeometryUtil.i(g, n, m);
                    return (i - 1) + o;
                }
                else if (e.j.containsKey(this.c7.item(i))) {
                    return i;
                }
                else {
                    return i - 1;
                }
            }
            return -1;
        }
        w0(a) {
            return this.w1(a, true);
        }
        wz(a) {
            let b = null;
            let c = 1.7976931348623157E+308;
            let d = this.te(a);
            let e = d.x;
            let f = d.y;
            if (this.vs.cz.e > this.w3) {
                return -1;
            }
            this.vs.c2((g) => {
                if (g._visibility == 0) {
                    let h = this.vs.cs(g);
                    let i = h.left + h.width / 2;
                    let j = h.top + h.height / 2;
                    let k = (e - i) * (e - i) + (f - j) * (f - j);
                    if (k < c) {
                        c = k;
                        b = g;
                    }
                }
            });
            if (b != null) {
                return b.ak;
            }
            return -1;
        }
        tj(a, b, c) {
            if (this.vo == null || this.vp == null || this.we == null || this.wf == null) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let d = this.cg.by;
            let e = this.cg.bx;
            let f = this.getEffectiveViewport();
            let g = new ScalerParams(0, d, e, this.vo.ch, f);
            let h = ((() => {
                let $ret = new ScalerParams(0, d, e, this.vp.ch, f);
                $ret.b = this.h3();
                return $ret;
            })());
            if (b) {
                let i = this.hw(a);
                if (i == -1) {
                    return { $type: Point_$type, x: NaN, y: NaN };
                }
                let j = truncate(Math.floor(i));
                let k = truncate(Math.ceil(i));
                if (j < 0) {
                    j = 0;
                }
                if (k < 0) {
                    k = 0;
                }
                if (k > this.c7.count - 1) {
                    k = this.c7.count - 1;
                }
                if (j > this.c7.count - 1) {
                    j = this.c7.count - 1;
                }
                if (k == j) {
                    return this.vq.h(this.we.item(j), this.wf.item(j), d, e, this.vr.e, this.vr.d, this.vr.g, this.vr.f, this.vr.i, this.vr.h);
                }
                let l = i - Math.floor(i);
                let m = this.vq.h(this.we.item(j), this.wf.item(j), d, e, this.vr.e, this.vr.d, this.vr.g, this.vr.f, this.vr.i, this.vr.h);
                let n = this.vq.h(this.we.item(k), this.wf.item(k), d, e, this.vr.e, this.vr.d, this.vr.g, this.vr.f, this.vr.i, this.vr.h);
                let o = m.x;
                let p = m.y;
                let q = n.x;
                let r = n.y;
                let s = q - o;
                let t = r - p;
                return { $type: Point_$type, x: o + s * l, y: p + t * l };
            }
            else {
                let u = this.i9(a);
                if (u == -1) {
                    return { $type: Point_$type, x: NaN, y: NaN };
                }
                return this.vq.h(this.we.item(u), this.wf.item(u), d, e, this.vr.e, this.vr.d, this.vr.g, this.vr.f, this.vr.i, this.vr.h);
            }
        }
        ag() {
            return [this.vo, this.vp];
        }
        jv(a, b) {
            let c = this.lw(b);
            if (c == PolarBase.$$p[3]) {
                return this.jw(a, b, this.xe);
            }
            if (c == PolarBase.$$p[15]) {
                return this.jw(a, b, this.xw);
            }
            return super.jv(a, b);
        }
        pa(a, b, c, d) {
            super.pa(a, b, c, d);
            if (this.vs.cy.g$b(a, b, c, d)) {
                this.pr(false);
                this.om();
            }
            switch (b) {
                case "FastItemsSource":
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.we);
                        c.deregisterColumn(this.wf);
                        this.we = null;
                        this.wf = null;
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.we = this.c4(this.xe);
                        this.wf = this.c4(this.xw);
                    }
                    if ((this.vp != null && !this.vp.c1()) || (this.vo != null && !this.vo.c1())) {
                        this.pr(this.fr && c != null);
                    }
                    break;
                case PolarBase.$$p[0]:
                    if (this.vo != null && this.vp != null) {
                        this.vq = new PolarAxes(this.vp, this.vo);
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if (this.vo != null && !this.vo.c1()) {
                        this.pr(false);
                    }
                    else if (c != null && d == null) {
                        this.nk(true, this.cg);
                    }
                    break;
                case PolarBase.$$p[12]:
                    if (this.vo != null && this.vp != null) {
                        this.vq = new PolarAxes(this.vp, this.vo);
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if (this.vp != null && !this.vp.c1()) {
                        this.pr(false);
                    }
                    else if (c != null && d == null) {
                        this.nk(true, this.cg);
                    }
                    if (this.vo != null && !this.vo.c1()) {
                        this.vo.h4();
                    }
                    break;
                case PolarBase.$$p[3]:
                    if (this.c7 != null) {
                        this.c7.deregisterColumn(this.we);
                        this.we = this.c4(this.xe);
                    }
                    break;
                case "AngleColumn":
                    this.vs.cy.g$i();
                    if (this.vo != null && !this.vo.c1()) {
                        this.pr(this.fr && this.dp);
                    }
                    break;
                case PolarBase.$$p[15]:
                    if (this.c7 != null) {
                        this.c7.deregisterColumn(this.wf);
                        this.wf = this.c4(this.xw);
                    }
                    break;
                case "RadiusColumn":
                    this.vs.cy.g$i();
                    if (this.vp != null && !this.vp.c1()) {
                        this.pr(this.fr && this.dp);
                    }
                    break;
                case PolarBase.$$p[16]:
                    this.pr(false);
                    this.om();
                    break;
                case PolarBase.$$p[11]:
                    this.pr(false);
                    this.om();
                    break;
                case "TransitionProgress":
                    this.vr = new PolarAxisInfoCache(this.vo, this.vp, this.c7);
                    this.y9 = this.cg.by;
                    this.y8 = this.cg.bx;
                    this.vz.v = this.wu;
                    this.vz.c(this.iw, this.vx, this.vv);
                    if (this.dm(this.cg)) {
                        return;
                    }
                    if (this.iw == 1) {
                        this.yc(this.vv, this.vs);
                        this.op();
                    }
                    else {
                        this.yc(this.vz, this.vs);
                    }
                    if (this.cv != null) {
                        this.cv.or(this);
                    }
                    break;
                case "TrendLineBrush":
                    this.pg(b);
                    break;
                case PolarBase.$$p[4]:
                    this.pr(false);
                    this.om();
                    break;
                case "TrendLineType":
                    this.om();
                    break;
                case PolarBase.$$p[8]:
                    this.wh = this.wq();
                    this.pr(false);
                    break;
                case PolarBase.$$p[7]:
                    this.wg = this.wp();
                    this.pr(false);
                    break;
                case PolarBase.$$p[9]:
                    this.v2 = this.v3();
                    break;
            }
        }
        get v2() {
            return this.v1;
        }
        set v2(a) {
            let b = this.v1;
            this.v1 = a;
            if (b != this.v1) {
                this.raisePropertyChanged("ActualItemSearchMode", enumGetBox(ScatterItemSearchMode_$type, b), enumGetBox(ScatterItemSearchMode_$type, this.v1));
            }
        }
        v3() {
            if (this.v4 != 0) {
                return this.v4;
            }
            return this.wo ? 4 : 1;
        }
        get_wo() {
            return false;
        }
        get wo() {
            return this.get_wo();
        }
        wq() {
            return this.wn;
        }
        wp() {
            return this.wm;
        }
        wj(a) {
            if (typeCast(NumericRadiusAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        wi(a) {
            if (typeCast(NumericAngleAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        nk(a, b) {
            super.nk(a, b);
            let c = b;
            if (a) {
                c.cz.clear();
            }
            c.cy.g$d();
        }
        vl(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;
        }
        x0(a, b, c, d) {
            a.g = new Dictionary$2(Base.$, OwnedPoint.$, 1, b);
            let e = this.c7;
            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.we.item(f), y: this.wf.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;
                    })()));
                }
            }
        }
        x8(a, b) {
            let c = b.by;
            let d = b.bx;
            a.j.clear();
            a.n.clear();
            let e = Math.min(this.we != null ? this.we.count : 0, this.wf != null ? this.wf.count : 0);
            if (e < 1) {
                return;
            }
            this.vr = new PolarAxisInfoCache(this.vo, this.vp, this.c7);
            this.vt = a;
            this.y8 = d;
            this.y9 = c;
            b.cw.l(a.j, this.w4, c, d, this.hk);
            if (e <= this.w4) {
                this.x0(a, e, c, d);
            }
            let f = this.vl(d, a.n);
            let g = Math.min(this.vo.lx, this.vo.lw);
            let h = Math.max(this.vo.lw, this.vo.lx);
            b.cy.i = this.wu;
            b.cy.h = 0;
            b.cy.k = this.vp.no;
            b.cy.j = this.vp.nn;
            b.cy.l = (i, j) => this.vq.c(i, j, c, d, Math.cos);
            b.cy.m = (i, j) => this.vq.d(i, j, c, d, Math.sin);
            let i = new List$1(Number_$type, 0);
            for (let j = 0; j < this.we.count; j++) {
                if (this.we.item(j) >= g && this.we.item(j) <= h) {
                    i.add(this.we.item(j));
                }
            }
            let k = this.wf;
            if (i.count != this.we.count) {
                k = new List$1(Number_$type, 0);
                for (let l = 0; l < this.we.count; l++) {
                    if (this.we.item(l) >= g && this.we.item(l) <= h) {
                        k.add(this.wf.item(l));
                    }
                }
            }
            b.cy.n(a.n, this.v6, i, k, this.w5, runOn(this.vo, this.vo.getScaledAngle), runOn(this.vp, this.vp.nu), ((() => {
                let $ret = new TrendResolutionParams();
                $ret.d = this.hk;
                $ret.h = d;
                $ret.i = c;
                return $ret;
            })()), f, g, h);
        }
        get_et() {
            return true;
        }
        v8(a, b, c) {
            return null;
        }
        v9(a, b, c) {
            let d = this.vw();
            let e = this.vs.b1(this.te(b));
            let f = -1;
            if (e == null) {
                if (a != null) {
                    f = this.c7.indexOf(a);
                }
                else {
                    return null;
                }
            }
            else {
                f = e.ak;
            }
            if (f == -1) {
                return null;
            }
            let g = new HighlightingInfo();
            g.i = this;
            g.g = f;
            g.f = f;
            g.c = false;
            g.d = true;
            if (c != null && c.g == g.g && c.f == g.f) {
                return c;
            }
            return g;
        }
        v7(a, b, c) {
            let d = new HighlightingInfo();
            d.i = this;
            d.g = 0;
            d.f = this.c7.count - 1;
            d.c = true;
            if (c != null && c.g == d.g && c.f == d.f) {
                return c;
            }
            return d;
        }
        c0(a, b, c) {
            if (this.dv && this.fd(this.bp) && !c) {
                let d = this.v8(a, b, this.wa);
                this.wa = d;
                return d;
            }
            else {
                let e = this.v7(a, b, this.wa);
                this.wa = e;
                return e;
            }
        }
        c1(a, b, c) {
            if (this.fd(this.bp) && !c) {
                let d = this.v9(a, b, this.wb);
                this.wb = d;
                return d;
            }
            else {
                let e = this.v7(a, b, this.wb);
                e.d = true;
                this.wb = e;
                return e;
            }
        }
        ws() {
            return (this.assigningPolarStyle != null && this.wh) || (this.bp != 1);
        }
        wr() {
            return (this.assigningPolarMarkerStyle != null && this.wg) || (this.bp != 1);
        }
        yc(a, b) {
            this.oy();
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = this.tq(b);
            this.vr = new PolarAxisInfoCache(this.vo, this.vp, this.c7);
            if (this.ue()) {
                b.cw.j(a.j, this.ug);
                if (this.wr()) {
                    this.x2(b, a);
                }
            }
            b.cp();
            let g = this.vl(d, b.cy.g$j.an);
            b.cy.g$h(a.n, g);
            this.xz(d, c, e, f, b);
        }
        vi(a, b) {
            return this.vj(a, b);
        }
        vj(a, b) {
            if (b < a || a < 0 || a > this.we.count || b < 0 || b > this.we.count) {
                return null;
            }
            let c = new Array((b - a) + 1);
            for (let d = a; d <= b; d++) {
                let e = d;
                c[d - a] = this.c7.item(d);
            }
            return c;
        }
        x2(a, b) {
            a.b6 = true;
            this.v0.ay(this, this.wr(), runOn(this, this.vi));
            let c = this.v0.d;
            let d = c != null;
            let e = this.getEffectiveViewport1(a);
            let f = this.c7 == null ? 0 : this.c7.count;
            this.vs.ci((g) => {
                if (g._visibility == 0) {
                    let h = g.ak;
                    let i = g.content;
                    if (i == null) {
                        i = new DataContext();
                        g.content = i;
                    }
                    if (d) {
                        this.x6(h, f, a.q);
                    }
                    this.v0.ac(g, i);
                }
            });
        }
        x7(a, b, c) {
            let d = this.bp != 1;
            this.v0.a0(this.v0.b, a, b, false);
            this.v0.ab(this.hi);
            let e = this.v0.ax;
            let f = null;
            let g = this.c7;
            if (d && this.cv != null) {
                f = this.cv.c2.getHighlightingInfo(this, g, e.o, e.n, false);
                e.b = f;
            }
            e.f = c;
            this.ya(e);
            this.v0.z(this, f, c, d, a < 0);
        }
        x6(a, b, c) {
            let d = this.bp != 1;
            this.v0.a0(this.v0.d, a, b, true);
            this.v0.aa(this.hi);
            let e = this.v0.aw;
            let f = null;
            let g = this.c7;
            let h = null;
            if (d && this.cv != null) {
                f = this.cv.c2.getHighlightingInfo(this, g, e.o, e.n, true);
                if (this.cv.c2.isCrossContextHighlight(this)) {
                    h = this.cv.c2.getHighlightingInfo(this, g, e.o, e.n, true);
                }
                e.b = f;
            }
            e.f = c;
            this.x9(e);
            this.v0.y(this, f, c, d, e.l, this.cv.c2.sumHighlightingProgress);
        }
        ya(a) {
            if (this.assigningPolarStyle != null && this.wh) {
                this.assigningPolarStyle(this, a);
            }
        }
        x9(a) {
            if (this.assigningPolarMarkerStyle != null && this.wg) {
                this.assigningPolarMarkerStyle(this, a);
            }
        }
        xz(a, b, c, d, e) {
            e.c1(a, b, c, d);
        }
        qf() {
            super.qf();
            if (this.index < 0) {
                return;
            }
            this.vs.c4();
        }
        pt(a, b) {
            super.pt(a, b);
            if (!this.f9) {
                this.cg.a4(b);
                return;
            }
            this.cg.a4(b);
            if (this.dm(this.cf)) {
                return;
            }
            let c = this.cf;
            if (!this.f2) {
                this.vy = new PolarFrame();
                this.x8(this.vy, c);
            }
            this.f2 = false;
            this.yc(this.vy, c);
            this.f9 = false;
        }
        pq(a, b, c, d, e) {
            super.pq(a, b, c, d, e);
            let f = this.a3.a$h.item(d);
            let g = f;
            f.a3(c);
            if (this.dm(g)) {
                return;
            }
            if (this.vu == null) {
                this.vu = new PolarFrame();
            }
            this.x8(this.vu, g);
            this.yc(this.vu, g);
        }
        yb(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.h(e);
            }
        }
        vh(a, b, c) {
            this.x3();
            return this.vt.w.toArray();
        }
        ww(a) {
            let b = new List$1(Number_$type, 0);
            let c = this.c7;
            for (let d of fromEnum(this.vs.cz.c)) {
                b.add(c.indexOf(d));
            }
            return b;
        }
        y6(a) {
            return { $type: Point_$type, x: this.we.item(a), y: this.wf.item(a) };
        }
        n2(a) {
            super.n2(a);
            this.a5.exportTrendlineData(this, a, this.vs.cy.g$j);
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.js(c);
            let e = d == null ? NaN : this.h2(d, "RadiusMemberPath");
            let f = d == null ? NaN : this.h2(d, "AngleMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 11;
            g.q = this.xw != null ? this.xw : "Radius";
            g.p = "Radius";
            g.r = this.xs != null ? this.xs : "R:";
            g.s = this.xu != null ? this.xu : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 10;
            h.q = this.xe != null ? this.xe : "Angle";
            h.p = "Angle";
            h.r = this.xa != null ? this.xa : "A:";
            h.s = this.xc != null ? this.xc : "";
            let i = new DataLegendSeriesContext();
            i.f = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.b = this.aw();
            return i;
        }
    }
    PolarBase.$t = /*@__PURE__*/ markType(PolarBase, 'PolarBase', MarkerSeries.$);
    PolarBase.yd = /*@__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:vo:ye', [NumericAngleAxis.$, null], 'AngleMemberAsLegendLabel:xa:yf', [2, null], 'AngleMemberAsLegendUnit:xc:yg', [2, null], 'AngleMemberPath:xe:yh', [2], 'ClipSeriesToBounds:wk:yi', [0, false], 'HighlightedAngleMemberPath:xh:yj', [2, null], 'HighlightedRadiusMemberPath:xj:yk', [2, null], 'IsCustomPolarMarkerStyleAllowed:wm:yl', [0, false], 'IsCustomPolarStyleAllowed:wn:ym', [0, false], 'ItemSearchMode:v4:yn', [ScatterItemSearchMode_$type, /*@__PURE__*/ enumGetBox(ScatterItemSearchMode_$type, 0)], 'ItemSearchThreshold:w3:yo', [1, 10000], 'MaximumMarkers:w4:yp', [1, 400], 'RadiusAxis:vp:yq', [NumericRadiusAxis.$, null], 'RadiusMemberAsLegendLabel:xs:yr', [2, null], 'RadiusMemberAsLegendUnit:xu:ys', [2, null], 'RadiusMemberPath:xw:yt', [2], 'UseCartesianInterpolation:wu:y1', [0, true], 'TrendLineType:v6:yz', [TrendLineType_$type, /*@__PURE__*/ enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness:w2:yy', [1, 1.5], 'TrendLinePeriod:w5:yx', [1, 7], 'TrendLineZIndex:w6:y0', [1, 1], 'TrendLineBrush:y3:yu', [Brush.$, null], 'TrendLineDashArray:y4:yv', [DoubleCollection.$], 'TrendLineDashCap:y5:yw', [PenLineCap_$type, /*@__PURE__*/ enumGetBox(PenLineCap_$type, 0)]]);
    return PolarBase;
})();
/**
 * @hidden
 */
export let PolarSeriesRenderManager = /*@__PURE__*/ (() => {
    class PolarSeriesRenderManager extends SeriesRenderManager {
        constructor() {
            super(...arguments);
            this.aw = null;
            this.ax = null;
        }
        c() {
            this.aw = new AssigningPolarMarkerStyleEventArgs();
            return this.aw;
        }
        a() {
            this.ax = new AssigningPolarStyleEventArgs();
            return this.ax;
        }
        ay(a, b, c) {
            this.w(a, b, c);
        }
        az(a, b, c) {
            this.x(a, b, c);
        }
        a0(a, b, c, d) {
            if (b == -1) {
                a.c = false;
                a.o = 0;
                a.n = c - 1;
            }
            else {
                if (d) {
                    a.o = b;
                    a.n = b;
                }
                else {
                    a.c = false;
                    a.o = b;
                    a.n = b;
                }
            }
        }
    }
    PolarSeriesRenderManager.$t = /*@__PURE__*/ markType(PolarSeriesRenderManager, 'PolarSeriesRenderManager', SeriesRenderManager.$);
    return PolarSeriesRenderManager;
})();
/**
 * @hidden
 */
export let PolarBaseView = /*@__PURE__*/ (() => {
    class PolarBaseView extends MarkerSeriesView {
        constructor(a) {
            super(a);
            this.cx = null;
            this.cw = null;
            this.cy = null;
            this.cz = null;
            this.cx = a;
            this.cz = new HashPool$2(Base.$, Marker.$);
            this.ck(this.cz);
            this.cy = new PolarTrendLineManager();
        }
        au() {
            super.au();
            this.cw = this.cv();
            if (!this.q) {
                this.cx.w4 = 1000;
                this.b4.uc = Defaults.e;
            }
        }
        c2(a) {
            this.cz.g(a);
        }
        cv() {
            let a = new NumericMarkerManager(0, (b) => this.cz.item(b), (b) => this.cx.vr.c.item(b), runOn(this, this.c3), runOn(this, this.cu), runOn(this, this.c0));
            a.n = true;
            a.p = runOn(this.cx, this.cx.y6);
            return a;
        }
        c3(a) {
            this.cx.yb(a, this.cz);
        }
        cu() {
            return this.cx.vh(this.cz, this.by, this.bx);
        }
        c0() {
            return this.cx.ww(this.cz);
        }
        c1(a, b, c, d) {
            if (this.cx.wk) {
                let e = new GeometryGroup();
                this.cx.vp.n2(e, a, b, c, d);
            }
            else {
            }
        }
        c4() {
            if (this.cx.y3 != null) {
                this.cx.y2 = this.cx.y3;
            }
            else {
                this.cx.y2 = this.cx.su;
            }
        }
        ci(a) {
            this.cz.f(a);
        }
        a7(a, b) {
            if (a.d) {
                if (this.cx.v6 != 0 && !b) {
                    let c = this.cy.g$j;
                    c.ad = this.cx.w2;
                    c._stroke = this.cx.y2;
                    c.aj = this.cx.y5;
                    c.ai = this.cx.y4;
                    a.v(c);
                }
            }
            super.a7(a, b);
        }
        c5() {
            return Rect.empty;
        }
        getDefaultTooltipTemplate() {
            let a = "<div class='ui-chart-default-tooltip-content'><span>" + "${item." + this.cx.xe + "}" + "</span><br/><span";
            let b = this.e.a3.a$r(this.e);
            if (!stringIsNullOrEmpty(b)) {
                a += " style='color:" + b + "'";
            }
            a += ">" + this.cx.title + ": </span><span class='ui-priority-primary'>" + "${item." + this.cx.xw + "}</span></div>";
            return a;
        }
    }
    PolarBaseView.$t = /*@__PURE__*/ markType(PolarBaseView, 'PolarBaseView', MarkerSeriesView.$);
    return PolarBaseView;
})();
