/*
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 { __extends, __values } from "tslib";
import { MarkerSeries } from "./MarkerSeries";
import { Base, runOn, Number_$type, enumGetBox, Point_$type, typeCast, 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 { ScatterItemSearchMode_$type } from "./ScatterItemSearchMode";
import { HighlightingInfo } from "./HighlightingInfo";
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 { Dictionary$2 } from "igniteui-angular-core";
import { OwnedPoint } from "./OwnedPoint";
import { GeometryUtil } from "igniteui-angular-core";
import { DataContext } from "igniteui-angular-core";
import { HashPool$2 } from "igniteui-angular-core";
import { Clipper } from "igniteui-angular-core";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { PolarTrendLineManager } from "./PolarTrendLineManager";
import { AssigningPolarStyleEventArgs } from "./AssigningPolarStyleEventArgs";
import { AssigningPolarMarkerStyleEventArgs } from "./AssigningPolarMarkerStyleEventArgs";
import { SeriesRenderManager } from "./SeriesRenderManager";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { truncate, isNaN_, isInfinity } from "igniteui-angular-core";
import { Defaults } from "./Defaults";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { GeometryGroup } from "igniteui-angular-core";
import { stringIsNullOrEmpty } from "igniteui-angular-core";
/**
 * @hidden
 */
var PolarBase = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(PolarBase, _super);
    function PolarBase() {
        var _this = _super.call(this) || this;
        _this.r3 = null;
        _this.rp = null;
        _this.r1 = null;
        _this.u5 = null;
        _this.u4 = null;
        _this.sf = null;
        _this.sh = null;
        _this.si = null;
        _this.r7 = new PolarFrame();
        _this.r9 = new PolarFrame();
        _this.r5 = new PolarFrame();
        _this.r0 = null;
        _this.sz = null;
        _this.sb = 1;
        _this.sm = false;
        _this.sl = false;
        _this.rw = null;
        _this.rx = null;
        _this.assigningPolarStyle = null;
        _this.assigningPolarMarkerStyle = null;
        _this.sa = null;
        _this.r8 = null;
        _this.r4 = null;
        _this.sa = new PolarSeriesRenderManager();
        _this.sc = _this.sd();
        _this.r8 = new PolarFrame();
        _this.r9.x = runOn(_this, _this.u3);
        _this.r7.x = runOn(_this, _this.u3);
        _this.r5.x = runOn(_this, _this.u3);
        _this.sf = new SeriesRenderer$2(PolarFrame.$, PolarBaseView.$, 0, runOn(_this, _this.t6), runOn(_this, _this.ua), runOn(_this, _this.cv), runOn(_this, _this.mu), runOn(_this, _this.t1));
        return _this;
    }
    PolarBase.prototype.bx = function () {
        return new PolarBaseView(this);
    };
    PolarBase.prototype.l2 = function (a) {
        _super.prototype.l2.call(this, a);
        this.r2 = a;
    };
    PolarBase.prototype.kx = function () {
        _super.prototype.kx.call(this);
        this.ry = null;
        this.rz = null;
    };
    PolarBase.prototype.get_d7 = function () {
        return true;
    };
    PolarBase.prototype.c1 = function (a, b, c, d) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var e = this.ry;
        var f = new ScalerParams(1, this.cd.s9, this.p3, e.cg);
        f.c = this.getEffectiveViewport1(this.b0);
        var g = this.rz;
        var h = new ScalerParams(1, this.cd.s9, this.p3, g.cg);
        h.c = this.getEffectiveViewport1(this.b0);
        a.clear();
        this.qg.cf(function (i) {
            if (i._visibility == 0) {
                var j = new SeriesPointOfInterest();
                var k = i.n;
                var l = i.o;
                if (k < _this.p3.left || k > _this.p3.right || l < _this.p3.top || l > _this.p3.bottom) {
                    return;
                }
                var m = void 0;
                var n = void 0;
                var o = _this.r0.f(k, l, _this.b0.bv, _this.b0.bu, m, n);
                m = o.p4;
                n = o.p5;
                j.b = m;
                j.c = n;
                j.a = i.content;
                a.add(j);
            }
        });
        return true;
    };
    PolarBase.prototype.t1 = function () {
        if (this.ce.g) {
            this.ce.t();
        }
    };
    PolarBase.prototype.t3 = function () {
        this.r0.e(this.r3.w, this.sj, this.sk, this.u5, this.u4, function (a, b) { return Math.cos(b); }, function (a, b) { return Math.sin(b); }, true);
    };
    Object.defineProperty(PolarBase.prototype, "sj", {
        get: function () {
            return this.sh;
        },
        set: function (a) {
            if (this.sh != a) {
                var b = this.sj;
                this.sh = a;
                this.raisePropertyChanged("AngleColumn", b, this.sj);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PolarBase.prototype, "sk", {
        get: function () {
            return this.si;
        },
        set: function (a) {
            if (this.si != a) {
                var b = this.sk;
                this.si = a;
                this.raisePropertyChanged("RadiusColumn", b, this.sk);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PolarBase.prototype, "uy", {
        get: function () {
            return this.c(PolarBase.ub);
        },
        set: function (a) {
            this.h(PolarBase.ub, a);
        },
        enumerable: false,
        configurable: true
    });
    PolarBase.prototype.r6 = function () {
        var a = this.r5;
        if (this.cv()) {
            if (this.ce.g) {
                this.ce.t();
            }
            a = this.r9;
        }
        return a;
    };
    PolarBase.prototype.li = function () {
        _super.prototype.li.call(this);
        if (this.rz != null) {
            this.rz.h7(false);
        }
        if (this.ry != null) {
            this.ry.h7(false);
        }
    };
    PolarBase.prototype.k3 = function (a, b, c, d) {
        var e = false;
        this.r2.cv.g$e(a, b, c, d);
        if (this.ry != null && !this.ry.c0()) {
            e = true;
        }
        if (this.rz != null && !this.rz.c0()) {
            e = true;
        }
        if (e) {
            this.ml(true);
        }
    };
    PolarBase.prototype.m8 = function (a, b) {
        this.ml(false);
    };
    PolarBase.prototype.m9 = function (a, b) {
        this.ml(false);
    };
    PolarBase.prototype.fb = function (a, b, c) {
        var d = true;
        if (!_super.prototype.fb.call(this, a, b, c) || !c.o() || b.isEmpty || a.isEmpty || this.ry == null || this.rz == null || this.sj == null || this.sk == null || this.sj.count == 0 || this.sk.count == 0 || this.ck == null || this.ck.count != this.sj.count || this.ck.count != this.sk.count || this.r0 == null || this.ry.bh == null || this.rz.bh == null || this.ry.lv == this.ry.lu || this.rz.lv == this.rz.lu) {
            d = false;
        }
        return d;
    };
    PolarBase.prototype.mm = function (a) {
        var b;
        var c;
        var d = this.getViewInfo(c, b);
        c = d.p0;
        b = d.p1;
        if (!this.fb(c, b, this.b0)) {
            this.k0(true, this.b0);
            return;
        }
        this.u5 = b;
        this.u4 = c;
        this.r1 = new PolarAxisInfoCache(this.ry, this.rz, this.ck);
        var e = new SeriesRenderingArguments(this, c, b, a, this.eu);
        var f = this.sf.g(e, this.r7, this.r5, this.r9, this.r2);
        this.r7 = f.p1;
        this.r5 = f.p2;
        this.r9 = f.p3;
    };
    PolarBase.prototype.u3 = function (a) {
        var b = this.r0.h(a.x, a.y, this.u5, this.u4, this.r1.e, this.r1.d, this.r1.g, this.r1.f, this.r1.i, this.r1.h);
        return b;
    };
    PolarBase.prototype.ap = function (a) {
        if (a != null && a == this.ry && this.sj != null) {
            return new AxisRange(this.sj.minimum, this.sj.maximum);
        }
        if (a != null && a == this.rz && this.sk != null) {
            return new AxisRange(this.sk.minimum, this.sk.maximum);
        }
        return null;
    };
    PolarBase.prototype.eo = function (a) {
        var b = this.b0.bv;
        b = b.copy();
        var c = this.b0.bu;
        var d = !b.isEmpty && !c.isEmpty && this.ck != null ? this.ck.indexOf(a) : -1;
        if (this.ry == null || this.sj == null || this.rz == null || this.sk == null) {
            return false;
        }
        if (d < 0 || d > this.sj.count - 1 || d > this.sk.count - 1) {
            return false;
        }
        var e = this.ry.getScaledAngle(this.sj.item(d));
        var f = this.rz.ns(this.sk.item(d));
        var g = 0.5 + (Math.cos(e) * f);
        var 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.b8 != null) {
            this.b8.au(this.cd, b, true);
        }
        return d >= 0;
    };
    PolarBase.prototype.hv = function (a) {
        var b = this.hf(a);
        if (this.ck != null && b >= 0 && b < this.ck.count) {
            return this.ck.item(b);
        }
        return null;
    };
    PolarBase.prototype.hf = function (a) {
        var b = truncate(Math.round(this.f7(a)));
        return b;
    };
    PolarBase.prototype.f7 = function (a) {
        switch (this.sc) {
            case 1: return this.s3(a);
            case 3: return this.s4(a);
            case 2: return this.s1(a);
            case 4: return this.s2(a);
        }
        return -1;
    };
    PolarBase.prototype.s2 = function (a) {
        return this.s5(a, false);
    };
    PolarBase.prototype.s1 = function (a) {
        var b = this.pl(a);
        var c = b.x;
        var d = b.y;
        if (this.ck == null || this.ry == null || this.rz == null || this.sj == null || this.sk == null) {
            return -1;
        }
        if (this.ck.count > this.s7) {
            return -1;
        }
        if (!this.sq()) {
            return -1;
        }
        var e = this.sz;
        var f = 1.7976931348623157E+308;
        var g = -1;
        for (var h = 0; h < this.sj.count; h++) {
            var i = e._inner[h].x;
            var j = e._inner[h].y;
            var k = (c - i) * (c - i) + (d - j) * (d - j);
            if (k < f) {
                f = k;
                g = h;
            }
        }
        return g;
    };
    PolarBase.prototype.sq = function () {
        var a = this.r5;
        if (this.cv()) {
            a = this.r9;
        }
        if (a == null || a.w.count == 0) {
            return false;
        }
        this.sz = a.w;
        return true;
    };
    PolarBase.prototype.s5 = function (a, b) {
        if (!this.st) {
            return -1;
        }
        var c = { $type: Point_$type, x: 0, y: 0 };
        var d = true;
        var e = this.r5;
        if (this.cv()) {
            e = this.r9;
        }
        if (e == null) {
            return -1;
        }
        if (e.m == null) {
            return -1;
        }
        if (this.ck == null || this.ck.count > this.s7) {
            return -1;
        }
        if (!this.sq()) {
            return -1;
        }
        var f = this.sz;
        var g = this.pl(a);
        var h = 1.7976931348623157E+308;
        var i = -1;
        for (var j = 0; j < f.count; j++) {
            var 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.ck.item(j)) || e.j.containsKey(this.ck.item(j - 1))) {
                    var l = GeometryUtil.d(g, c, k);
                    if (l < h) {
                        h = l;
                        i = j;
                    }
                }
            }
            c = k;
        }
        if (i >= 0) {
            var m = f._inner[i];
            var n = f._inner[i - 1];
            if (!b || (e.j.containsKey(this.ck.item(i)) && e.j.containsKey(this.ck.item(i - 1)))) {
                var o = GeometryUtil.h(g, n, m);
                return (i - 1) + o;
            }
            else if (e.j.containsKey(this.ck.item(i))) {
                return i;
            }
            else {
                return i - 1;
            }
        }
        return -1;
    };
    PolarBase.prototype.s4 = function (a) {
        return this.s5(a, true);
    };
    PolarBase.prototype.s3 = function (a) {
        var _this = this;
        var b = null;
        var c = 1.7976931348623157E+308;
        var d = this.pl(a);
        var e = d.x;
        var f = d.y;
        if (this.r2.cw.e > this.s7) {
            return -1;
        }
        this.r2.cz(function (g) {
            if (g._visibility == 0) {
                var h = _this.r2.cp(g);
                var i = h.left + h.width / 2;
                var j = h.top + h.height / 2;
                var k = (e - i) * (e - i) + (f - j) * (f - j);
                if (k < c) {
                    c = k;
                    b = g;
                }
            }
        });
        if (b != null) {
            return b.ak;
        }
        return -1;
    };
    PolarBase.prototype.pq = function (a, b, c) {
        var _this = this;
        if (this.ry == null || this.rz == null || this.sj == null || this.sk == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.b0.bv;
        var e = this.b0.bu;
        var f = this.getEffectiveViewport();
        var g = new ScalerParams(0, d, e, this.ry.cg, f);
        var h = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.rz.cg, f);
            $ret.b = _this.ge();
            return $ret;
        })());
        if (b) {
            var i = this.f7(a);
            if (i == -1) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            var j = truncate(Math.floor(i));
            var k = truncate(Math.ceil(i));
            if (j < 0) {
                j = 0;
            }
            if (k < 0) {
                k = 0;
            }
            if (k > this.ck.count - 1) {
                k = this.ck.count - 1;
            }
            if (j > this.ck.count - 1) {
                j = this.ck.count - 1;
            }
            if (k == j) {
                return this.r0.h(this.sj.item(j), this.sk.item(j), d, e, this.r1.e, this.r1.d, this.r1.g, this.r1.f, this.r1.i, this.r1.h);
            }
            var l = i - Math.floor(i);
            var m = this.r0.h(this.sj.item(j), this.sk.item(j), d, e, this.r1.e, this.r1.d, this.r1.g, this.r1.f, this.r1.i, this.r1.h);
            var n = this.r0.h(this.sj.item(k), this.sk.item(k), d, e, this.r1.e, this.r1.d, this.r1.g, this.r1.f, this.r1.i, this.r1.h);
            var o = m.x;
            var p = m.y;
            var q = n.x;
            var r = n.y;
            var s = q - o;
            var t = r - p;
            return { $type: Point_$type, x: o + s * l, y: p + t * l };
        }
        else {
            var u = this.hf(a);
            if (u == -1) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            return this.r0.h(this.sj.item(u), this.sk.item(u), d, e, this.r1.e, this.r1.d, this.r1.g, this.r1.f, this.r1.i, this.r1.h);
        }
    };
    PolarBase.prototype.ag = function () {
        return [this.ry, this.rz];
    };
    PolarBase.prototype.hy = function (a, b) {
        var c = this.js(b);
        if (c == PolarBase.$$p[3]) {
            return this.hz(a, b, this.ti);
        }
        if (c == PolarBase.$$p[13]) {
            return this.hz(a, b, this.tw);
        }
        return _super.prototype.hy.call(this, a, b);
    };
    PolarBase.prototype.l7 = function (a, b, c, d) {
        _super.prototype.l7.call(this, a, b, c, d);
        if (this.r2.cv.g$b(a, b, c, d)) {
            this.ml(false);
            this.ls();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.sj);
                    c.deregisterColumn(this.sk);
                    this.sj = null;
                    this.sk = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.sj = this.ch(this.ti);
                    this.sk = this.ch(this.tw);
                }
                if ((this.rz != null && !this.rz.c0()) || (this.ry != null && !this.ry.c0())) {
                    this.ml(false);
                }
                break;
            case PolarBase.$$p[0]:
                if (this.ry != null && this.rz != null) {
                    this.r0 = new PolarAxes(this.rz, this.ry);
                }
                if (c != null) {
                    c.bz(this);
                }
                if (d != null) {
                    d.cs(this);
                }
                if (this.ry != null && !this.ry.c0()) {
                    this.ml(false);
                }
                else if (c != null && d == null) {
                    this.k0(true, this.b0);
                }
                break;
            case PolarBase.$$p[10]:
                if (this.ry != null && this.rz != null) {
                    this.r0 = new PolarAxes(this.rz, this.ry);
                }
                if (c != null) {
                    c.bz(this);
                }
                if (d != null) {
                    d.cs(this);
                }
                if (this.rz != null && !this.rz.c0()) {
                    this.ml(false);
                }
                else if (c != null && d == null) {
                    this.k0(true, this.b0);
                }
                if (this.ry != null && !this.ry.c0()) {
                    this.ry.h3();
                }
                break;
            case PolarBase.$$p[3]:
                if (this.ck != null) {
                    this.ck.deregisterColumn(this.sj);
                    this.sj = this.ch(this.ti);
                }
                break;
            case "AngleColumn":
                this.r2.cv.g$i();
                if (this.ry != null && !this.ry.c0()) {
                    this.ml(false);
                }
                break;
            case PolarBase.$$p[13]:
                if (this.ck != null) {
                    this.ck.deregisterColumn(this.sk);
                    this.sk = this.ch(this.tw);
                }
                break;
            case "RadiusColumn":
                this.r2.cv.g$i();
                if (this.rz != null && !this.rz.c0()) {
                    this.ml(false);
                }
                break;
            case PolarBase.$$p[14]:
                this.ml(false);
                this.ls();
                break;
            case PolarBase.$$p[9]:
                this.ml(false);
                this.ls();
                break;
            case "TransitionProgress":
                this.r1 = new PolarAxisInfoCache(this.ry, this.rz, this.ck);
                this.u5 = this.b0.bv;
                this.u4 = this.b0.bu;
                this.r9.v = this.sy;
                this.r9.c(this.g2, this.r7, this.r5);
                if (this.cx(this.b0)) {
                    return;
                }
                if (this.g2 == 1) {
                    this.ua(this.r5, this.r2);
                }
                else {
                    this.ua(this.r9, this.r2);
                }
                if (this.cd != null) {
                    this.cd.oa(this);
                }
                break;
            case "TrendLineBrush":
                this.mz();
                break;
            case PolarBase.$$p[4]:
                this.ml(false);
                this.ls();
                break;
            case "TrendLineType":
                this.ls();
                break;
            case PolarBase.$$p[6]:
                this.sm = this.sv();
                this.ml(false);
                break;
            case PolarBase.$$p[5]:
                this.sl = this.su();
                this.ml(false);
                break;
            case PolarBase.$$p[7]:
                this.sc = this.sd();
                break;
        }
    };
    Object.defineProperty(PolarBase.prototype, "sc", {
        get: function () {
            return this.sb;
        },
        set: function (a) {
            var b = this.sb;
            this.sb = a;
            if (b != this.sb) {
                this.raisePropertyChanged("ActualItemSearchMode", enumGetBox(ScatterItemSearchMode_$type, b), enumGetBox(ScatterItemSearchMode_$type, this.sb));
            }
        },
        enumerable: false,
        configurable: true
    });
    PolarBase.prototype.sd = function () {
        if (this.se != 0) {
            return this.se;
        }
        return this.st ? 4 : 1;
    };
    PolarBase.prototype.get_st = function () {
        return false;
    };
    Object.defineProperty(PolarBase.prototype, "st", {
        get: function () {
            return this.get_st();
        },
        enumerable: false,
        configurable: true
    });
    PolarBase.prototype.sv = function () {
        return this.ss;
    };
    PolarBase.prototype.su = function () {
        return this.sr;
    };
    PolarBase.prototype.so = function (a) {
        if (typeCast(NumericRadiusAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    PolarBase.prototype.sn = function (a) {
        if (typeCast(NumericAngleAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    PolarBase.prototype.k0 = function (a, b) {
        _super.prototype.k0.call(this, a, b);
        var c = b;
        if (a) {
            c.cw.clear();
        }
        c.cv.g$d();
    };
    PolarBase.prototype.rq = function (a, b) {
        var c = a.top - 10;
        var d = a.bottom + 10;
        var e = a.left - 10;
        var f = a.right + 10;
        var g = ((function () {
            var $ret = new Clipper(1, e, d, f, c, false);
            $ret.i = b;
            return $ret;
        })());
        return g;
    };
    PolarBase.prototype.t0 = function (a, b, c, d) {
        a.g = new Dictionary$2(Base.$, OwnedPoint.$, 1, b);
        var e = this.ck;
        var _loop_1 = function (f) {
            var g = a.w._inner[f];
            if (!isInfinity(g.x) && !isInfinity(g.y)) {
                var h_1 = { $type: Point_$type, x: this_1.sj.item(f), y: this_1.sk.item(f) };
                var i_1 = { $type: Point_$type, x: g.x, y: g.y };
                a.g.addItem(e.item(f), ((function () {
                    var $ret = new OwnedPoint();
                    $ret.a = e.item(f);
                    $ret.b = h_1;
                    $ret.c = i_1;
                    return $ret;
                })()));
            }
        };
        var this_1 = this;
        for (var f = 0; f < b; f++) {
            _loop_1(f);
        }
    };
    PolarBase.prototype.t6 = function (a, b) {
        var _this = this;
        var c = b.bv;
        var d = b.bu;
        a.j.clear();
        a.n.clear();
        var e = Math.min(this.sj != null ? this.sj.count : 0, this.sk != null ? this.sk.count : 0);
        if (e < 1) {
            return;
        }
        this.r1 = new PolarAxisInfoCache(this.ry, this.rz, this.ck);
        this.r3 = a;
        this.u4 = d;
        this.u5 = c;
        b.ct.l(a.j, this.s8, c, d, this.fv);
        if (e <= this.s8) {
            this.t0(a, e, c, d);
        }
        var f = this.rq(d, a.n);
        var g = Math.min(this.ry.lv, this.ry.lu);
        var h = Math.max(this.ry.lu, this.ry.lv);
        b.cv.i = this.sy;
        b.cv.h = 0;
        b.cv.k = this.rz.nm;
        b.cv.j = this.rz.nl;
        b.cv.l = function (i, j) { return _this.r0.c(i, j, c, d, Math.cos); };
        b.cv.m = function (i, j) { return _this.r0.d(i, j, c, d, Math.sin); };
        var i = new List$1(Number_$type, 0);
        for (var j = 0; j < this.sj.count; j++) {
            if (this.sj.item(j) >= g && this.sj.item(j) <= h) {
                i.add(this.sj.item(j));
            }
        }
        var k = this.sk;
        if (i.count != this.sj.count) {
            k = new List$1(Number_$type, 0);
            for (var l = 0; l < this.sj.count; l++) {
                if (this.sj.item(l) >= g && this.sj.item(l) <= h) {
                    k.add(this.sk.item(l));
                }
            }
        }
        b.cv.n(a.n, this.sg, i, k, this.s9, runOn(this.ry, this.ry.getScaledAngle), runOn(this.rz, this.rz.ns), ((function () {
            var $ret = new TrendResolutionParams();
            $ret.b = _this.fv;
            $ret.f = d;
            $ret.g = c;
            return $ret;
        })()), f, g, h);
    };
    PolarBase.prototype.get_dy = function () {
        return true;
    };
    PolarBase.prototype.ru = function (a, b, c) {
        return null;
    };
    PolarBase.prototype.rv = function (a, b, c) {
        var d = this.r6();
        var e = this.r2.by(this.pl(b));
        var f = -1;
        if (e == null) {
            if (a != null) {
                f = this.ck.indexOf(a);
            }
            else {
                return null;
            }
        }
        else {
            f = e.ak;
        }
        if (f == -1) {
            return null;
        }
        var g = new HighlightingInfo();
        g.b = this;
        g.h = f;
        g.g = f;
        g.d = false;
        g.e = true;
        if (c != null && c.h == g.h && c.g == g.g) {
            return c;
        }
        return g;
    };
    PolarBase.prototype.rt = function (a, b, c) {
        var d = new HighlightingInfo();
        d.b = this;
        d.h = 0;
        d.g = this.ck.count - 1;
        d.d = true;
        if (c != null && c.h == d.h && c.g == d.g) {
            return c;
        }
        return d;
    };
    PolarBase.prototype.aw = function (a, b, c) {
        if (this.c2 && this.eg(this.bk) && !c) {
            var d = this.ru(a, b, this.rw);
            this.rw = d;
            return d;
        }
        else {
            var e = this.rt(a, b, this.rw);
            this.rw = e;
            return e;
        }
    };
    PolarBase.prototype.ax = function (a, b, c) {
        if (this.eg(this.bk) && !c) {
            var d = this.rv(a, b, this.rx);
            this.rx = d;
            return d;
        }
        else {
            var e = this.rt(a, b, this.rx);
            e.e = true;
            this.rx = e;
            return e;
        }
    };
    PolarBase.prototype.sx = function () {
        return (this.assigningPolarStyle != null && this.sm) || (this.bk != 1);
    };
    PolarBase.prototype.sw = function () {
        return (this.assigningPolarMarkerStyle != null && this.sl) || (this.bk != 1);
    };
    PolarBase.prototype.ua = function (a, b) {
        var c = b.bv;
        var d = b.bu;
        var e = this.getEffectiveViewport1(b);
        var f = this.pv(b);
        this.r1 = new PolarAxisInfoCache(this.ry, this.rz, this.ck);
        if (this.qj()) {
            b.ct.j(a.j, this.ql);
            if (this.sw()) {
                this.t2(b, a);
            }
        }
        b.cm();
        var g = this.rq(d, b.cv.g$j.ak);
        b.cv.g$h(a.n, g);
        this.tz(d, c, e, f, b);
    };
    PolarBase.prototype.rn = function (a, b) {
        return this.ro(a, b);
    };
    PolarBase.prototype.ro = function (a, b) {
        if (b < a || a < 0 || a > this.sj.count || b < 0 || b > this.sj.count) {
            return null;
        }
        var c = new Array((b - a) + 1);
        for (var d = a; d <= b; d++) {
            var e = d;
            c[d - a] = this.ck.item(d);
        }
        return c;
    };
    PolarBase.prototype.t2 = function (a, b) {
        var _this = this;
        a.b3 = true;
        this.sa.aw(this, this.sw(), runOn(this, this.rn));
        var c = this.sa.d;
        var d = c != null;
        var e = this.getEffectiveViewport1(a);
        var f = this.ck == null ? 0 : this.ck.count;
        this.r2.cf(function (g) {
            if (g._visibility == 0) {
                var h = g.ak;
                var i = g.content;
                if (i == null) {
                    i = new DataContext();
                    g.content = i;
                }
                if (d) {
                    _this.t4(h, f, a.q);
                }
                _this.sa.ac(g, i);
            }
        });
    };
    PolarBase.prototype.t5 = function (a, b, c) {
        var d = this.bk != 1;
        this.sa.ay(this.sa.b, a, b, false);
        this.sa.ab(this.ft);
        var e = this.sa.av;
        var f = null;
        var g = this.ck;
        if (d && this.cd != null) {
            f = this.cd.a7.getHighlightingInfo(this, g, e.o, e.n, false);
            e.b = f;
        }
        e.f = c;
        this.t8(e);
        this.sa.z(this, f, c, d, a < 0);
    };
    PolarBase.prototype.t4 = function (a, b, c) {
        var d = this.bk != 1;
        this.sa.ay(this.sa.d, a, b, true);
        this.sa.aa(this.ft);
        var e = this.sa.au;
        var f = null;
        var g = this.ck;
        var h = null;
        if (d && this.cd != null) {
            f = this.cd.a7.getHighlightingInfo(this, g, e.o, e.n, true);
            if (this.cd.a7.isCrossSeriesHighlight(this)) {
                h = this.cd.a7.getHighlightingInfo(this, g, e.o, e.n, true);
            }
            e.b = f;
        }
        e.f = c;
        this.t7(e);
        this.sa.y(this, f, c, d, e.l, this.cd.a7.sumHighlightingProgress);
    };
    PolarBase.prototype.t8 = function (a) {
        if (this.assigningPolarStyle != null && this.sm) {
            this.assigningPolarStyle(this, a);
        }
    };
    PolarBase.prototype.t7 = function (a) {
        if (this.assigningPolarMarkerStyle != null && this.sl) {
            this.assigningPolarMarkerStyle(this, a);
        }
    };
    PolarBase.prototype.tz = function (a, b, c, d, e) {
        e.cy(a, b, c, d);
    };
    PolarBase.prototype.mz = function () {
        _super.prototype.mz.call(this);
        if (this.index < 0) {
            return;
        }
        this.r2.c1();
    };
    PolarBase.prototype.mn = function (a, b) {
        _super.prototype.mn.call(this, a, b);
        if (!this.e1) {
            this.b0.a2(b);
            return;
        }
        this.b0.a2(b);
        if (this.cx(this.bz)) {
            return;
        }
        var c = this.bz;
        if (!this.ev) {
            this.r8 = new PolarFrame();
            this.t6(this.r8, c);
        }
        this.ev = false;
        this.ua(this.r8, c);
        this.e1 = false;
    };
    PolarBase.prototype.mk = function (a, b, c, d, e) {
        _super.prototype.mk.call(this, a, b, c, d, e);
        var f = this.a6.a$h.item(d);
        var g = f;
        f.a1(c);
        if (this.cx(g)) {
            return;
        }
        if (this.r4 == null) {
            this.r4 = new PolarFrame();
        }
        this.t6(this.r4, g);
        this.ua(this.r4, g);
    };
    PolarBase.prototype.t9 = function (a, b) {
        var e_1, _a, e_2, _b;
        var c = new List$1(Base.$, 0);
        try {
            for (var _c = __values(fromEnum(b.c)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var d = _d.value;
                if (!a.containsKey(d)) {
                    c.add1(d);
                }
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        try {
            for (var _e = __values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var e = _f.value;
                b.h(e);
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
    };
    PolarBase.prototype.rm = function (a, b, c) {
        this.t3();
        return this.r3.w.toArray();
    };
    PolarBase.prototype.s0 = function (a) {
        var e_3, _a;
        var b = new List$1(Number_$type, 0);
        var c = this.ck;
        try {
            for (var _b = __values(fromEnum(this.r2.cw.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var d = _c.value;
                b.add(c.indexOf(d));
            }
        }
        catch (e_3_1) {
            e_3 = { error: e_3_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_3)
                    throw e_3.error;
            }
        }
        return b;
    };
    PolarBase.prototype.u2 = function (a) {
        return { $type: Point_$type, x: this.sj.item(a), y: this.sk.item(a) };
    };
    PolarBase.prototype.la = function (a) {
        _super.prototype.la.call(this, a);
        this.a8.exportTrendlineData(this, a, this.r2.cv.g$j);
    };
    PolarBase.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.hv(c);
        var e = d == null ? NaN : this.gd(d, "RadiusMemberPath");
        var f = d == null ? NaN : this.gd(d, "AngleMemberPath");
        var g = new DataLegendSeriesValueInfo();
        g.l = e;
        g.a = 11;
        g.q = this.tw != null ? this.tw : "Radius";
        g.p = "Radius";
        g.r = this.ts != null ? this.ts : "R:";
        g.s = this.tu != null ? this.tu : "";
        var h = new DataLegendSeriesValueInfo();
        h.l = f;
        h.a = 10;
        h.q = this.ti != null ? this.ti : "Angle";
        h.p = "Angle";
        h.r = this.te != null ? this.te : "A:";
        h.s = this.tg != null ? this.tg : "";
        var i = new DataLegendSeriesContext();
        i.f = ((function () {
            var $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
            $ret.add(g);
            $ret.add(h);
            return $ret;
        })());
        i.b = this.av();
        return i;
    };
    PolarBase.$t = markType(PolarBase, 'PolarBase', MarkerSeries.$);
    PolarBase.ub = DependencyProperty.i("ActualTrendLineBrush", Brush.$, PolarBase.$, new PropertyMetadata(2, null, function (a, b) { return a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue); }));
    PolarBase.$$p = markDep(DependencyProperty, PropertyMetadata, PolarBase, 'raisePropertyChanged', ['AngleAxis:ry:uc', [NumericAngleAxis.$, null], 'AngleMemberAsLegendLabel:te:ud', [2, null], 'AngleMemberAsLegendUnit:tg:ue', [2, null], 'AngleMemberPath:ti:uf', [2], 'ClipSeriesToBounds:sp:ug', [0, false], 'IsCustomPolarMarkerStyleAllowed:sr:uh', [0, false], 'IsCustomPolarStyleAllowed:ss:ui', [0, false], 'ItemSearchMode:se:uj', [ScatterItemSearchMode_$type, enumGetBox(ScatterItemSearchMode_$type, 0)], 'ItemSearchThreshold:s7:uk', [1, 10000], 'MaximumMarkers:s8:ul', [1, 400], 'RadiusAxis:rz:um', [NumericRadiusAxis.$, null], 'RadiusMemberAsLegendLabel:ts:un', [2, null], 'RadiusMemberAsLegendUnit:tu:uo', [2, null], 'RadiusMemberPath:tw:up', [2], 'UseCartesianInterpolation:sy:ux', [0, true], 'TrendLineType:sg:uv', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness:s6:uu', [1, 1.5], 'TrendLinePeriod:s9:ut', [1, 7], 'TrendLineZIndex:ta:uw', [1, 1], 'TrendLineBrush:uz:uq', [Brush.$, null], 'TrendLineDashArray:u0:ur', [DoubleCollection.$], 'TrendLineDashCap:u1:us', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
    return PolarBase;
}(MarkerSeries));
export { PolarBase };
/**
 * @hidden
 */
var PolarSeriesRenderManager = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(PolarSeriesRenderManager, _super);
    function PolarSeriesRenderManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.au = null;
        _this.av = null;
        return _this;
    }
    PolarSeriesRenderManager.prototype.c = function () {
        this.au = new AssigningPolarMarkerStyleEventArgs();
        return this.au;
    };
    PolarSeriesRenderManager.prototype.a = function () {
        this.av = new AssigningPolarStyleEventArgs();
        return this.av;
    };
    PolarSeriesRenderManager.prototype.aw = function (a, b, c) {
        this.w(a, b, c);
    };
    PolarSeriesRenderManager.prototype.ax = function (a, b, c) {
        this.x(a, b, c);
    };
    PolarSeriesRenderManager.prototype.ay = function (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 = markType(PolarSeriesRenderManager, 'PolarSeriesRenderManager', SeriesRenderManager.$);
    return PolarSeriesRenderManager;
}(SeriesRenderManager));
export { PolarSeriesRenderManager };
/**
 * @hidden
 */
var PolarBaseView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(PolarBaseView, _super);
    function PolarBaseView(a) {
        var _this = _super.call(this, a) || this;
        _this.cu = null;
        _this.ct = null;
        _this.cv = null;
        _this.cw = null;
        _this.cu = a;
        _this.cw = new HashPool$2(Base.$, Marker.$);
        _this.ch(_this.cw);
        _this.cv = new PolarTrendLineManager();
        return _this;
    }
    PolarBaseView.prototype.as = function () {
        _super.prototype.as.call(this);
        this.ct = this.cs();
        if (!this.q) {
            this.cu.s8 = 1000;
            this.b1.qh = Defaults.e;
        }
    };
    PolarBaseView.prototype.cz = function (a) {
        this.cw.g(a);
    };
    PolarBaseView.prototype.cs = function () {
        var _this = this;
        var a = new NumericMarkerManager(0, function (b) { return _this.cw.item(b); }, function (b) { return _this.cu.r1.c.item(b); }, runOn(this, this.c0), runOn(this, this.cr), runOn(this, this.cx));
        a.n = true;
        a.p = runOn(this.cu, this.cu.u2);
        return a;
    };
    PolarBaseView.prototype.c0 = function (a) {
        this.cu.t9(a, this.cw);
    };
    PolarBaseView.prototype.cr = function () {
        return this.cu.rm(this.cw, this.bv, this.bu);
    };
    PolarBaseView.prototype.cx = function () {
        return this.cu.s0(this.cw);
    };
    PolarBaseView.prototype.cy = function (a, b, c, d) {
        if (this.cu.sp) {
            var e = new GeometryGroup();
            this.cu.rz.n0(e, a, b, c, d);
        }
        else {
        }
    };
    PolarBaseView.prototype.c1 = function () {
        if (this.cu.uz != null) {
            this.cu.uy = this.cu.uz;
        }
        else {
            this.cu.uy = this.cu.o3;
        }
    };
    PolarBaseView.prototype.cf = function (a) {
        this.cw.f(a);
    };
    PolarBaseView.prototype.a5 = function (a, b) {
        if (a.d) {
            if (this.cu.sg != 0 && !b) {
                var c = this.cv.g$j;
                c.ac = this.cu.s6;
                c._stroke = this.cu.uy;
                c.ad = this.cu.u1;
                c.ai = this.cu.u0;
                a.v(c);
            }
        }
        _super.prototype.a5.call(this, a, b);
    };
    PolarBaseView.prototype.c2 = function () {
        return Rect.empty;
    };
    PolarBaseView.prototype.getDefaultTooltipTemplate = function () {
        var a = "<div class='ui-chart-default-tooltip-content'><span>" + "${item." + this.cu.ti + "}" + "</span><br/><span";
        var b = this.e.a6.a$r(this.e);
        if (!stringIsNullOrEmpty(b)) {
            a += " style='color:" + b + "'";
        }
        a += ">" + this.cu.title + ": </span><span class='ui-priority-primary'>" + "${item." + this.cu.tw + "}</span></div>";
        return a;
    };
    PolarBaseView.$t = markType(PolarBaseView, 'PolarBaseView', MarkerSeriesView.$);
    return PolarBaseView;
}(MarkerSeriesView));
export { PolarBaseView };
