/*
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 { Base, markType, runOn, EnumUtil, typeCast, fromEnum, markDep } from "igniteui-angular-core";
import { IBucketizer_$type } from "./IBucketizer";
import { NotImplementedException } from "igniteui-angular-core";
import { CategoryAngleAxis } from "./CategoryAngleAxis";
import { NumericRadiusAxis } from "./NumericRadiusAxis";
import { truncate, intDivide, isNaN_ } from "igniteui-angular-core";
import { MarkerSeries } from "./MarkerSeries";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { SeriesRenderer$2 } from "./SeriesRenderer$2";
import { RadialFrame } from "./RadialFrame";
import { DependencyProperty } from "igniteui-angular-core";
import { HighlightingInfo } from "./HighlightingInfo";
import { RadialSeriesRenderManager } from "./RadialSeriesRenderManager";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { RadialAxes } from "./RadialAxes";
import { Visibility_$type } from "igniteui-angular-core";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { PropertyMetadata } from "igniteui-angular-core";
import { round10N } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
/**
 * @hidden
 */
export let RadialBucketCalculator = /*@__PURE__*/ (() => {
    class RadialBucketCalculator extends Base {
        constructor(a) {
            super();
            this.a = null;
            this.c = 0;
            this.d = 0;
            this.b = 0;
            this.a = a;
        }
        getBucket(a) {
            throw new NotImplementedException(0);
        }
        getBucketWithoutUnknowns(a) {
            return this.getBucket(a);
        }
        getErrorBucket(a, b) {
            return NaN;
        }
        getBucketInfo(a, b, c, d) {
            a = this.c;
            b = this.d;
            c = this.b;
            d = this.a.cr.ft;
            return {
                p0: a,
                p1: b,
                p2: c,
                p3: d
            };
        }
        e(a) {
            let b = this.a.bv;
            let c = this.a.bu;
            let d = this.a.cr.rk;
            if (b.isEmpty || c.isEmpty || d == null || this.a.cr.ck == null || this.a.cr.ck.count == 0) {
                this.b = 0;
                return;
            }
            let e = Math.floor(d.mw(c, b));
            let f = Math.ceil(d.mv(c, b));
            if (d.cg) {
                f = Math.ceil(d.mw(c, b));
                e = Math.floor(d.mv(c, b));
            }
            if (f < e) {
                f = d.le + f;
            }
            let g = this.a.cr.rr;
            let h = g != null ? g.nm : 0.75;
            let i = Math.min(c.width, c.height) * 0.5 * (h) * 2 * Math.PI;
            let j = Math.floor((f - e + 1) * a / i);
            this.b = truncate(Math.max(1, j));
            this.c = truncate(Math.max(0, Math.floor(e / this.b) - 1));
            this.d = truncate(Math.ceil(f / this.b));
        }
        cacheValues() {
        }
        unCacheValues() {
        }
    }
    RadialBucketCalculator.$t = markType(RadialBucketCalculator, 'RadialBucketCalculator', Base.$, [IBucketizer_$type]);
    return RadialBucketCalculator;
})();
/**
 * @hidden
 */
export let RadialBase = /*@__PURE__*/ (() => {
    class RadialBase extends MarkerSeries {
        constructor() {
            super();
            this.ry = null;
            this.rz = null;
            this.r1 = false;
            this.r0 = false;
            this.rp = null;
            this.rq = null;
            this.assigningRadialStyle = null;
            this.assigningRadialMarkerStyle = null;
            this.rw = new RadialFrame(3);
            this.rx = new RadialFrame(3);
            this.ru = new RadialFrame(3);
            this.rs = null;
            this.ry = new RadialSeriesRenderManager();
            this.rz = new SeriesRenderer$2(RadialFrame.$, RadialBaseView.$, 1, runOn(this, this.sm), runOn(this, this.sp), runOn(this, this.cv), runOn(this, this.mq), runOn(this, this.sl), (a) => this.rt.cs.e(this.ft));
        }
        ly(a) {
            super.ly(a);
            this.rt = a;
        }
        sl() {
            if (this.ce.g) {
                this.ce.t();
            }
        }
        get categoryAxis() {
            return this.rk;
        }
        ar() {
            return this.rk;
        }
        rh(a, b) {
            return null;
        }
        c1(a, b, c, d) {
            if (!this.hasMarkers) {
                return false;
            }
            let e = this.rk;
            let f = new ScalerParams(1, this.cd.sf, this.py, e.cg);
            f.c = this.getEffectiveViewport1(this.b0);
            let g = this.rr;
            let h = new ScalerParams(1, this.cd.sf, this.py, g.cg);
            h.c = this.getEffectiveViewport1(this.b0);
            a.clear();
            this.qb.cf((i) => {
                if (i._visibility == 0) {
                    let j = new SeriesPointOfInterest();
                    let k = i.n;
                    let l = i.o;
                    if (k < this.py.left || k > this.py.right || l < this.py.top || l > this.py.bottom) {
                        return;
                    }
                    let m;
                    let n;
                    let o = this.rs.g(k, l, this.b0.bv, this.b0.bu, m, n);
                    m = o.p4;
                    n = o.p5;
                    j.b = m;
                    j.c = n;
                    if (b) {
                        if (c) {
                            j.d = this.sg(j.c, d);
                        }
                        else {
                            let p = this.go(i);
                            if (!isNaN_(p)) {
                                j.d = this.sg(p, d);
                            }
                            else {
                                j.d = this.sg(j.c, d);
                            }
                        }
                    }
                    else {
                        j.d = e.gc(i.ak);
                    }
                    j.a = i.content;
                    a.add(j);
                }
            });
            return true;
        }
        sg(a, b) {
            if (b >= 0) {
                return round10N(a, b).toString();
            }
            else {
                return a.toString();
            }
        }
        get_ea() {
            return true;
        }
        get_dx() {
            return true;
        }
        rm(a, b, c) {
            let 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;
        }
        rn(a, b, c) {
            let d = this.rt.cs.c;
            let e = this.rt.cs.d;
            let f = this.rt.cs.b;
            let g = this.rv();
            let h = this.ck.count;
            let i = this.rk;
            let j = -1;
            let k = -1;
            let l = this.hd(b);
            j = truncate(Math.floor((intDivide(l, f)))) * f;
            k = j + (f - 1);
            if (c != null && c.h == j && c.g == k) {
                return c;
            }
            let m = new HighlightingInfo();
            m.b = this;
            m.h = j;
            m.g = k;
            return m;
        }
        ro(a, b, c) {
            let d = this.rt.cs.c;
            let e = this.rt.cs.d;
            let f = this.rt.cs.b;
            let g = this.rv();
            let h = this.ck.count;
            let i = this.rk;
            let j = -1;
            let k = -1;
            let l = this.hd(b);
            j = truncate(Math.floor((intDivide(l, f)))) * f;
            k = j + (f - 1);
            if (c != null && c.h == j && c.g == k) {
                return c;
            }
            let m = new HighlightingInfo();
            m.e = true;
            m.b = this;
            m.h = j;
            m.g = k;
            return m;
        }
        aw(a, b, c) {
            if (this.c2 && this.ef(this.bk) && !c) {
                let d = this.rn(a, b, this.rp);
                this.rp = d;
                return d;
            }
            else {
                let e = this.rm(a, b, this.rp);
                this.rp = e;
                return e;
            }
        }
        ax(a, b, c) {
            if (this.ef(this.bk) && !c) {
                let d = this.ro(a, b, this.rq);
                this.rq = d;
                return d;
            }
            else {
                let e = this.rm(a, b, this.rq);
                e.e = true;
                this.rq = e;
                return e;
            }
        }
        sa() {
            return (this.assigningRadialStyle != null && this.r1) || (this.bk != 1);
        }
        r9() {
            return (this.assigningRadialMarkerStyle != null && this.r0) || (this.bk != 1);
        }
        so(a) {
            if (this.assigningRadialStyle != null && this.r1) {
                this.assigningRadialStyle(this, a);
            }
        }
        sn(a) {
            if (this.assigningRadialMarkerStyle != null && this.r0) {
                this.assigningRadialMarkerStyle(this, a);
            }
        }
        sc(a) {
            return a.cs.b;
        }
        sd(a) {
            return a.cs.c;
        }
        ag() {
            return [this.rk, this.rr];
        }
        m5(a, b) {
            this.rt.cs.e(this.ft);
            this.mh(false);
        }
        m4(a, b) {
            this.rt.cs.e(this.ft);
            this.mh(false);
        }
        l3(a, b, c, d) {
            super.l3(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    if (c != null && d == null) {
                        if (this.rk != null) {
                            this.rk.bz(this);
                        }
                        if (this.rr != null) {
                            this.rr.bz(this);
                        }
                    }
                    if (c == null && d != null) {
                        if (this.rk != null) {
                            this.rk.cs(this);
                        }
                        if (this.rr != null) {
                            this.rr.cs(this);
                        }
                    }
                    this.rt.cs.e(this.ft);
                    this.mh(false);
                    break;
                case RadialBase.$$p[0]:
                    if (this.rk != null && this.rr != null) {
                        this.rs = new RadialAxes(this.rr, this.rk);
                    }
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    this.rt.cs.e(this.ft);
                    this.mh(false);
                    break;
                case RadialBase.$$p[4]:
                    if (this.rk != null && this.rr != null) {
                        this.rs = new RadialAxes(this.rr, this.rk);
                    }
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    this.rt.cs.e(this.ft);
                    if (this.rr == null || !this.rr.c0()) {
                        this.mh(false);
                    }
                    break;
                case "SyncLink":
                    if (this.b8 != null && this.cd != null) {
                        this.rt.cs.e(this.ft);
                        this.mh(false);
                    }
                    break;
                case "TransitionProgress":
                    this.rx.c(this.g0, this.rw, this.ru);
                    if (this.cx(this.b0)) {
                        return;
                    }
                    if (this.g0 == 1) {
                        this.sp(this.ru, this.rt);
                    }
                    else {
                        this.sp(this.rx, this.rt);
                    }
                    if (this.cd != null) {
                        this.cd.nn(this);
                    }
                    break;
                case RadialBase.$$p[1]:
                    this.mh(false);
                    this.lo();
                    break;
                case "VisibilityProxy":
                    if (EnumUtil.getEnumValue(Visibility_$type, c) != 0 && EnumUtil.getEnumValue(Visibility_$type, d) == 0) {
                        this.rt.cs.e(this.ft);
                    }
                    break;
                case RadialBase.$$p[3]:
                    this.r1 = this.r8();
                    this.mh(false);
                    break;
                case RadialBase.$$p[2]:
                    this.r0 = this.r7();
                    this.mh(false);
                    break;
            }
        }
        r8() {
            return this.r6;
        }
        r7() {
            return this.r5;
        }
        r3(a) {
            if (typeCast(NumericRadiusAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        r2(a) {
            if (typeCast(CategoryAngleAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        ht(a) {
            let b = this.hd(a);
            return b >= 0 && this.ck != null && b < this.ck.count ? this.ck.item(b) : null;
        }
        sb(a) {
            let b = this.b0.bv;
            let c = this.b0.bu;
            if (this.rk != null && !b.isEmpty && !c.isEmpty && this.rs != null) {
                let d = this.rs.c(a);
                if (d < 0) {
                    d += Math.PI * 2;
                }
                if (d > Math.PI * 2) {
                    d -= Math.PI * 2;
                }
                return d;
            }
            return NaN;
        }
        f5(a) {
            let b = this.b0.bv;
            let c = this.b0.bu;
            let d = -1;
            if (this.rk != null && !b.isEmpty && !c.isEmpty && this.rs != null) {
                let e = this.rs.c(a);
                if (e < 0) {
                    e += Math.PI * 2;
                }
                if (e > Math.PI * 2) {
                    e -= Math.PI * 2;
                }
                let f = this.rk.getUnscaledAngle(e);
                if (this.rk.categoryMode != 0) {
                    f -= 0.5;
                }
                d = f;
            }
            return d;
        }
        hd(a) {
            let b = truncate(Math.round(this.f5(a)));
            if (this.ck != null && b == this.ck.count) {
                b = 0;
            }
            return b;
        }
        en(a) {
            return false;
        }
        rv() {
            let a = this.ru;
            if (this.cv()) {
                if (this.ce.g) {
                    this.ce.t();
                }
                a = this.rx;
            }
            return a;
        }
        le() {
            super.le();
            if (this.rk != null) {
                this.rk.h7(false);
            }
            if (this.rr != null) {
                this.rr.h7(false);
            }
        }
        e9(a, b, c) {
            let d = true;
            let e = c;
            if (!super.e9(a, b, c) || !c.o() || b.isEmpty || a.isEmpty || this.rk == null || this.rk.itemsSource == null || this.rr == null || this.rs == null || this.ck == null || this.rk.bh == null || this.rr.bh == null || this.rr.lv == this.rr.lu) {
                e.cs.b = 0;
                d = false;
            }
            return d;
        }
        mi(a) {
            let b;
            let c;
            let d = this.getViewInfo(c, b);
            c = d.p0;
            b = d.p1;
            if (!this.e9(c, b, this.b0)) {
                this.kx(true, this.b0);
                return;
            }
            let e = new SeriesRenderingArguments(this, c, b, a, this.es);
            let f = this.rz.g(e, this.rw, this.ru, this.rx, this.rt);
            this.rw = f.p1;
            this.ru = f.p2;
            this.rx = f.p3;
        }
        se() {
            let a = 0;
            for (let b of fromEnum(this.cd.series)) {
                if (b == this) {
                    return a;
                }
                let c = typeCast(RadialBase.$, b);
                if (c != null && c.rk == this.rk && c.preferredCategoryMode(c.rk) == 2) {
                    a++;
                }
            }
            return -1;
        }
    }
    RadialBase.$t = markType(RadialBase, 'RadialBase', MarkerSeries.$, [IHasCategoryModePreference_$type]);
    RadialBase.$$p = markDep(DependencyProperty, PropertyMetadata, RadialBase, 'raisePropertyChanged', ['AngleAxis:rk:sq', [CategoryAngleAxis.$, null], 'ClipSeriesToBounds:r4:sr', [0, false], 'IsCustomRadialMarkerStyleAllowed:r5:ss', [0, false], 'IsCustomRadialStyleAllowed:r6:st', [0, false], 'ValueAxis:rr:su', [NumericRadiusAxis.$, null]]);
    return RadialBase;
})();
/**
 * @hidden
 */
export let RadialBaseView = /*@__PURE__*/ (() => {
    class RadialBaseView extends MarkerSeriesView {
        constructor(a) {
            super(a);
            this.cs = null;
            this.cr = null;
            this.ct = null;
            this.cu = 0;
            this.cv = null;
            this.cr = a;
            this.ct = new Pool$1(Marker.$);
            this.ci(this.ct);
        }
        cf(a) {
            this.ct.c(a);
        }
    }
    RadialBaseView.$t = markType(RadialBaseView, 'RadialBaseView', MarkerSeriesView.$);
    return RadialBaseView;
})();
