/*
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, delegateCombine, EnumUtil, typeCast, fromEnum, markDep } from "igniteui-react-core";
import { IBucketizer_$type } from "./IBucketizer";
import { NotImplementedException } from "igniteui-react-core";
import { CategoryAngleAxis } from "./CategoryAngleAxis";
import { NumericRadiusAxis } from "./NumericRadiusAxis";
import { truncate, intDivide, isNaN_ } from "igniteui-react-core";
import { MarkerSeries } from "./MarkerSeries";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { SeriesRenderer$2 } from "./SeriesRenderer$2";
import { RadialFrame } from "./RadialFrame";
import { DependencyProperty } from "igniteui-react-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 { SeriesLayerPropertyOverlay } from "./SeriesLayerPropertyOverlay";
import { DoubleCollection } from "igniteui-react-core";
import { RadialAxes } from "./RadialAxes";
import { Visibility_$type } from "igniteui-react-core";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { PropertyMetadata } from "igniteui-react-core";
import { round10N } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-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.cu.hj;
            return {
                p0: a,
                p1: b,
                p2: c,
                p3: d
            };
        }
        e(a) {
            let b = this.a.by;
            let c = this.a.bx;
            let d = this.a.cu.vi;
            if (b.isEmpty || c.isEmpty || d == null || this.a.cu.c6 == null || this.a.cu.c6.count == 0) {
                this.b = 0;
                return;
            }
            let e = Math.floor(d.mx(c, b));
            let f = Math.ceil(d.mw(c, b));
            if (d.ch) {
                f = Math.ceil(d.mx(c, b));
                e = Math.floor(d.mw(c, b));
            }
            if (f < e) {
                f = d.lf + f;
            }
            let g = this.a.cu.vp;
            let h = g != null ? g.no : 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 = /*@__PURE__*/ markType(RadialBucketCalculator, 'RadialBucketCalculator', Base.$, [IBucketizer_$type]);
    return RadialBucketCalculator;
})();
/**
 * @hidden
 */
export let RadialBase = /*@__PURE__*/ (() => {
    class RadialBase extends MarkerSeries {
        o0(a) {
            super.o0(a);
            this.vr = a;
        }
        constructor() {
            super();
            this.vw = null;
            this.vx = null;
            this.vz = false;
            this.vy = false;
            this.vn = null;
            this.vo = null;
            this.assigningRadialStyle = null;
            this.assigningRadialMarkerStyle = null;
            this.vu = new RadialFrame(3);
            this.vv = new RadialFrame(3);
            this.vs = new RadialFrame(3);
            this.vq = null;
            this.vw = new RadialSeriesRenderManager();
            this.vx = new SeriesRenderer$2(RadialFrame.$, RadialBaseView.$, 1, runOn(this, this.wl), runOn(this, this.wo), runOn(this, this.dj), runOn(this, this.p3), runOn(this, this.wk), (a) => this.vr.cv.e(this.hj));
        }
        wk() {
            if (this.cz.g) {
                this.cz.t();
            }
        }
        get categoryAxis() {
            return this.vi;
        }
        as() {
            return this.vi;
        }
        vf(a, b) {
            return null;
        }
        ds(a, b, c, d) {
            if (!this.hasMarkers) {
                return false;
            }
            let e = this.vi;
            let f = new ScalerParams(1, this.cy.tn, this.tw, e.ch);
            f.c = this.getEffectiveViewport1(this.cj);
            let g = this.vp;
            let h = new ScalerParams(1, this.cy.tn, this.tw, g.ch);
            h.c = this.getEffectiveViewport1(this.cj);
            a.clear();
            this.t9.ci((i) => {
                if (i._visibility == 0) {
                    let j = new SeriesPointOfInterest();
                    let k = i.n;
                    let l = i.o;
                    if (k < this.tw.left || k > this.tw.right || l < this.tw.top || l > this.tw.bottom) {
                        return;
                    }
                    let m;
                    let n;
                    let o = this.vq.g(k, l, this.cj.by, this.cj.bx, m, n);
                    m = o.p4;
                    n = o.p5;
                    j.b = m;
                    j.c = n;
                    if (b) {
                        if (c) {
                            j.d = this.wf(j.c, d);
                        }
                        else {
                            let p = this.ih(i);
                            if (!isNaN_(p)) {
                                j.d = this.wf(p, d);
                            }
                            else {
                                j.d = this.wf(j.c, d);
                            }
                        }
                    }
                    else {
                        j.d = e.gd(i.ak);
                    }
                    j.a = i.content;
                    a.add(j);
                }
            });
            return true;
        }
        wf(a, b) {
            if (b >= 0) {
                return round10N(a, b).toString();
            }
            else {
                return a.toString();
            }
        }
        get_e6() {
            return true;
        }
        get_es() {
            return true;
        }
        vk(a, b, c) {
            let d = new HighlightingInfo();
            d.b = this;
            d.h = 0;
            d.g = this.c6.count - 1;
            d.d = true;
            if (c != null && c.h == d.h && c.g == d.g) {
                return c;
            }
            return d;
        }
        v9() {
            return false;
        }
        g0() {
            let a = super.g0();
            if (this.v9()) {
                let b = ((() => {
                    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(b);
            }
            if (!this.v9()) {
                let c = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.r = true;
                    $ret.ad = "Brush";
                    $ret.p = true;
                    $ret.y = "ActualBrush";
                    $ret.q = true;
                    return $ret;
                })());
                c.valueResolving = delegateCombine(c.valueResolving, runOn(this, this.px));
                a.add(c);
            }
            if (!this.v9()) {
                let d = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.r = true;
                    $ret.ad = "Outline";
                    $ret.p = true;
                    $ret.y = "ActualOutline";
                    $ret.q = true;
                    return $ret;
                })());
                d.valueResolving = delegateCombine(d.valueResolving, runOn(this, this.px));
                a.add(d);
            }
            return a;
        }
        vl(a, b, c) {
            let d = this.vr.cv.c;
            let e = this.vr.cv.d;
            let f = this.vr.cv.b;
            let g = this.vt();
            let h = this.c6.count;
            let i = this.vi;
            let j = -1;
            let k = -1;
            let l = this.i8(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;
        }
        vm(a, b, c) {
            let d = this.vr.cv.c;
            let e = this.vr.cv.d;
            let f = this.vr.cv.b;
            let g = this.vt();
            let h = this.c6.count;
            let i = this.vi;
            let j = -1;
            let k = -1;
            let l = this.i8(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;
        }
        ax(a, b, c) {
            if (this.du && this.fc(this.bs) && !c) {
                let d = this.vl(a, b, this.vn);
                this.vn = d;
                return d;
            }
            else {
                let e = this.vk(a, b, this.vn);
                this.vn = e;
                return e;
            }
        }
        ay(a, b, c) {
            if (this.fc(this.bs) && !c) {
                let d = this.vm(a, b, this.vo);
                this.vo = d;
                return d;
            }
            else {
                let e = this.vk(a, b, this.vo);
                e.e = true;
                this.vo = e;
                return e;
            }
        }
        v8() {
            return (this.assigningRadialStyle != null && this.vz) || (this.bs != 1);
        }
        v7() {
            return (this.assigningRadialMarkerStyle != null && this.vy) || (this.bs != 1);
        }
        wn(a) {
            if (this.assigningRadialStyle != null && this.vz) {
                this.assigningRadialStyle(this, a);
            }
        }
        wm(a) {
            if (this.assigningRadialMarkerStyle != null && this.vy) {
                this.assigningRadialMarkerStyle(this, a);
            }
        }
        wb(a) {
            return a.cv.b;
        }
        wc(a) {
            return a.cv.c;
        }
        ag() {
            return [this.vi, this.vp];
        }
        qn(a, b) {
            this.vr.cv.e(this.hj);
            this.pp(false);
        }
        qm(a, b) {
            this.vr.cv.e(this.hj);
            this.pp(false);
        }
        o8(a, b, c, d) {
            super.o8(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    if (c != null && d == null) {
                        if (this.vi != null) {
                            this.vi.b0(this);
                        }
                        if (this.vp != null) {
                            this.vp.b0(this);
                        }
                    }
                    if (c == null && d != null) {
                        if (this.vi != null) {
                            this.vi.ct(this);
                        }
                        if (this.vp != null) {
                            this.vp.ct(this);
                        }
                    }
                    this.vr.cv.e(this.hj);
                    this.pp(false);
                    break;
                case RadialBase.$$p[0]:
                    if (this.vi != null && this.vp != null) {
                        this.vq = new RadialAxes(this.vp, this.vi);
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    this.vr.cv.e(this.hj);
                    this.pp(false);
                    break;
                case RadialBase.$$p[4]:
                    if (this.vi != null && this.vp != null) {
                        this.vq = new RadialAxes(this.vp, this.vi);
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    this.vr.cv.e(this.hj);
                    if (this.vp == null || !this.vp.c1()) {
                        this.pp(false);
                    }
                    break;
                case "SyncLink":
                    if (this.cr != null && this.cy != null) {
                        this.vr.cv.e(this.hj);
                        this.pp(false);
                    }
                    break;
                case "TransitionProgress":
                    this.vv.c(this.iv, this.vu, this.vs);
                    if (this.dl(this.cj)) {
                        return;
                    }
                    if (this.iv == 1) {
                        this.wo(this.vs, this.vr);
                    }
                    else {
                        this.wo(this.vv, this.vr);
                    }
                    if (this.cy != null) {
                        this.cy.on(this);
                    }
                    break;
                case RadialBase.$$p[1]:
                    this.pp(false);
                    this.ol();
                    break;
                case "VisibilityProxy":
                    if (EnumUtil.getEnumValue(Visibility_$type, c) != 0 && EnumUtil.getEnumValue(Visibility_$type, d) == 0) {
                        this.vr.cv.e(this.hj);
                    }
                    break;
                case RadialBase.$$p[3]:
                    this.vz = this.v6();
                    this.pp(false);
                    break;
                case RadialBase.$$p[2]:
                    this.vy = this.v5();
                    this.pp(false);
                    break;
            }
        }
        v6() {
            return this.v4;
        }
        v5() {
            return this.v3;
        }
        v1(a) {
            if (typeCast(NumericRadiusAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        v0(a) {
            if (typeCast(CategoryAngleAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        jr(a) {
            let b = this.i8(a);
            return b >= 0 && this.c6 != null && b < this.c6.count ? this.c6.item(b) : null;
        }
        wa(a) {
            let b = this.cj.by;
            let c = this.cj.bx;
            if (this.vi != null && !b.isEmpty && !c.isEmpty && this.vq != null) {
                let d = this.vq.c(a);
                if (d < 0) {
                    d += Math.PI * 2;
                }
                if (d > Math.PI * 2) {
                    d -= Math.PI * 2;
                }
                return d;
            }
            return NaN;
        }
        hv(a) {
            let b = this.cj.by;
            let c = this.cj.bx;
            let d = -1;
            if (this.vi != null && !b.isEmpty && !c.isEmpty && this.vq != null) {
                let e = this.vq.c(a);
                if (e < 0) {
                    e += Math.PI * 2;
                }
                if (e > Math.PI * 2) {
                    e -= Math.PI * 2;
                }
                let f = this.vi.getUnscaledAngle(e);
                if (this.vi.categoryMode != 0) {
                    f -= 0.5;
                }
                d = f;
            }
            return d;
        }
        i8(a) {
            let b = truncate(Math.round(this.hv(a)));
            if (this.c6 != null && b == this.c6.count) {
                b = 0;
            }
            return b;
        }
        fo(a) {
            return false;
        }
        vt() {
            let a = this.vs;
            if (this.dj()) {
                if (this.cz.g) {
                    this.cz.t();
                }
                a = this.vv;
            }
            return a;
        }
        ob() {
            super.ob();
            if (this.vi != null) {
                this.vi.h8(false);
            }
            if (this.vp != null) {
                this.vp.h8(false);
            }
        }
        gl(a, b, c) {
            let d = true;
            let e = c;
            if (!super.gl(a, b, c) || !c.o() || b.isEmpty || a.isEmpty || this.vi == null || this.vi.itemsSource == null || this.vp == null || this.vq == null || this.c6 == null || this.vi.bi == null || this.vp.bi == null || this.vp.lx == this.vp.lw) {
                e.cv.b = 0;
                d = false;
            }
            return d;
        }
        pq(a) {
            super.pq(a);
            let b;
            let c;
            let d = this.getViewInfo(c, b);
            c = d.p0;
            b = d.p1;
            if (!this.gl(c, b, this.cj)) {
                this.nj(true, this.cj);
                return;
            }
            let e = new SeriesRenderingArguments(this, c, b, a, this.f0);
            let f = this.vx.g(e, this.vu, this.vs, this.vv, this.vr);
            this.vu = f.p1;
            this.vs = f.p2;
            this.vv = f.p3;
        }
        wd() {
            let a = 0;
            for (let b of fromEnum(this.cy.series)) {
                if (b == this || this.bi == b) {
                    return a;
                }
                let c = typeCast(RadialBase.$, b);
                if (c != null && c.vi == this.vi && c.preferredCategoryMode(c.vi) == 2) {
                    a++;
                }
            }
            return -1;
        }
    }
    RadialBase.$t = /*@__PURE__*/ markType(RadialBase, 'RadialBase', MarkerSeries.$, [IHasCategoryModePreference_$type]);
    RadialBase.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, RadialBase, 'raisePropertyChanged', ['AngleAxis:vi:wp', [CategoryAngleAxis.$, null], 'ClipSeriesToBounds:v2:wq', [0, false], 'IsCustomRadialMarkerStyleAllowed:v3:wr', [0, false], 'IsCustomRadialStyleAllowed:v4:ws', [0, false], 'ValueAxis:vp:wt', [NumericRadiusAxis.$, null]]);
    return RadialBase;
})();
/**
 * @hidden
 */
export let RadialBaseView = /*@__PURE__*/ (() => {
    class RadialBaseView extends MarkerSeriesView {
        constructor(a) {
            super(a);
            this.cv = null;
            this.cu = null;
            this.cw = null;
            this.cx = 0;
            this.cy = null;
            this.cu = a;
            this.cw = new Pool$1(Marker.$);
            this.cl(this.cw);
        }
        ci(a) {
            this.cw.c(a);
        }
    }
    RadialBaseView.$t = /*@__PURE__*/ markType(RadialBaseView, 'RadialBaseView', MarkerSeriesView.$);
    return RadialBaseView;
})();
