/*
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, Type, markType, runOn, EnumUtil, typeCast, fromEnum } from "igniteui-react-core/ES2015/type";
import { IBucketizer_$type } from "./IBucketizer";
import { NotImplementedException } from "igniteui-react-core/ES2015/NotImplementedException";
import { CategoryAngleAxis } from "./CategoryAngleAxis";
import { NumericRadiusAxis } from "./NumericRadiusAxis";
import { truncate } from "igniteui-react-core/ES2015/number";
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/ES2015/DependencyProperty";
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-react-core/ES2015/Visibility";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
import { Pool$1 } from "igniteui-react-core/ES2015/Pool$1";
export 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.cn.eq;
        return {
            p0: a,
            p1: b,
            p2: c,
            p3: d
        };
    }
    e(a) {
        let b = this.a.bs;
        let c = this.a.br;
        let d = this.a.cn.mr;
        if (b.isEmpty || c.isEmpty || d == null || this.a.cn.bz == null || this.a.cn.bz.count == 0) {
            this.b = 0;
            return;
        }
        let e = Math.floor(d.k6(c, b));
        let f = Math.ceil(d.k5(c, b));
        if (d.b8) {
            f = Math.ceil(d.k6(c, b));
            e = Math.floor(d.k5(c, b));
        }
        if (f < e) {
            f = d.jr + f;
        }
        let g = this.a.cn.mt;
        let h = g != null ? g.lc : 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]);
export class RadialBase extends MarkerSeries {
    constructor() {
        super();
        this.mz = null;
        this.mx = new RadialFrame(3);
        this.my = new RadialFrame(3);
        this.mw = new RadialFrame(3);
        this.mu = null;
        this.mz = new SeriesRenderer$2(RadialFrame.$, RadialBaseView.$, 1, runOn(this, this.nb), runOn(this, this.nc), runOn(this, this.ca), runOn(this, this.jc), runOn(this, this.na), (a) => this.mv.co.e(this.eq));
    }
    il(a) {
        super.il(a);
        this.mv = a;
    }
    na() {
        if (this.bt.g) {
            this.bt.t();
        }
    }
    get categoryAxis() {
        return this.mr;
    }
    ap() {
        return this.mr;
    }
    m3(a) {
        if (!this.hasMarkers) {
            return false;
        }
        let b = this.mr;
        let c = new ScalerParams(1, this.bs.mn, this.lp, b.b8);
        c.c = this.getEffectiveViewport1(this.bi);
        let d = this.mt;
        let e = new ScalerParams(1, this.bs.mn, this.lp, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.lr.cc((f) => {
            if (f._visibility == 0) {
                let g = new SeriesPointOfInterest();
                let h = f.n;
                let i = f.o;
                if (h < this.lp.left || h > this.lp.right || i < this.lp.top || i > this.lp.bottom) {
                    return;
                }
                g.b = b.dw(h, c);
                g.c = d.dw(i, e);
                g.d = b.fe(f.ak);
                g.a = f.content;
                a.add(g);
            }
        });
        return true;
    }
    get_c2() {
        return true;
    }
    ag() {
        return [this.mr, this.mt];
    }
    jk(a, b) {
        this.mv.co.e(this.eq);
        this.i4(false);
    }
    jj(a, b) {
        this.mv.co.e(this.eq);
        this.i4(false);
    }
    ir(a, b, c, d) {
        super.ir(a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (c != null && d == null) {
                    if (this.mr != null) {
                        this.mr.bv(this);
                    }
                    if (this.mt != null) {
                        this.mt.bv(this);
                    }
                }
                if (c == null && d != null) {
                    if (this.mr != null) {
                        this.mr.ch(this);
                    }
                    if (this.mt != null) {
                        this.mt.ch(this);
                    }
                }
                this.mv.co.e(this.eq);
                this.i4(false);
                break;
            case RadialBase.$$p[0]:
                if (this.mr != null && this.mt != null) {
                    this.mu = new RadialAxes(this.mt, this.mr);
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                this.mv.co.e(this.eq);
                this.i4(false);
                break;
            case RadialBase.$$p[2]:
                if (this.mr != null && this.mt != null) {
                    this.mu = new RadialAxes(this.mt, this.mr);
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                this.mv.co.e(this.eq);
                if (this.mt == null || !this.mt.ck()) {
                    this.i4(false);
                }
                break;
            case "SyncLink":
                if (this.bn != null && this.bs != null) {
                    this.mv.co.e(this.eq);
                    this.i4(false);
                }
                break;
            case "TransitionProgress":
                this.my.c(this.ev, this.mx, this.mw);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.ev == 1) {
                    this.nc(this.mw, this.mv);
                }
                else {
                    this.nc(this.my, this.mv);
                }
                if (this.bs != null) {
                    this.bs.jh(this);
                }
                break;
            case RadialBase.$$p[1]:
                this.i4(false);
                this.ib();
                break;
            case "VisibilityProxy":
                if (EnumUtil.getEnumValue(Visibility_$type, c) != 0 && EnumUtil.getEnumValue(Visibility_$type, d) == 0) {
                    this.mv.co.e(this.eq);
                }
                break;
        }
    }
    m1(a) {
        if (typeCast(NumericRadiusAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    m0(a) {
        if (typeCast(CategoryAngleAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    fl(a) {
        let b = this.e4(a);
        return b >= 0 && this.bz != null && b < this.bz.count ? this.bz.item(b) : null;
    }
    m4(a) {
        let b = this.bi.bs;
        let c = this.bi.br;
        if (this.mr != null && !b.isEmpty && !c.isEmpty && this.mu != null) {
            let d = this.mu.c(a);
            if (d < 0) {
                d += Math.PI * 2;
            }
            if (d > Math.PI * 2) {
                d -= Math.PI * 2;
            }
            return d;
        }
        return NaN;
    }
    m5(a) {
        let b = this.bi.bs;
        let c = this.bi.br;
        let d = -1;
        if (this.mr != null && !b.isEmpty && !c.isEmpty && this.mu != null) {
            let e = this.mu.c(a);
            if (e < 0) {
                e += Math.PI * 2;
            }
            if (e > Math.PI * 2) {
                e -= Math.PI * 2;
            }
            let f = this.mr.getUnscaledAngle(e);
            if (this.mr.categoryMode != 0) {
                f -= 0.5;
            }
            d = f;
        }
        return d;
    }
    e4(a) {
        let b = truncate(Math.round(this.m5(a)));
        if (this.bz != null && b == this.bz.count) {
            b = 0;
        }
        return b;
    }
    c7(a) {
        return false;
    }
    h3() {
        super.h3();
        if (this.mr != null) {
            this.mr.g0(false);
        }
        if (this.mt != null) {
            this.mt.g0(false);
        }
    }
    du(a, b, c) {
        let d = true;
        let e = c;
        if (!super.du(a, b, c) || !c.l() || b.isEmpty || a.isEmpty || this.mr == null || this.mr.itemsSource == null || this.mt == null || this.mu == null || this.bz == null || this.mr.bf == null || this.mt.bf == null || this.mt.jx == this.mt.jw) {
            e.co.b = 0;
            d = false;
        }
        return d;
    }
    i5(a) {
        let b;
        let c;
        let d = this.getViewInfo(c, b);
        c = d.p0;
        b = d.p1;
        if (!this.du(c, b, this.bi)) {
            this.ho(true, this.bi);
            return;
        }
        let e = new SeriesRenderingArguments(this, c, b, a, this.dc);
        let f = this.mz.g(e, this.mx, this.mw, this.my, this.mv);
        this.mx = f.p1;
        this.mw = f.p2;
        this.my = f.p3;
    }
    m6() {
        let a = 0;
        for (let b of fromEnum(this.bs.series)) {
            if (b == this) {
                return a;
            }
            let c = typeCast(RadialBase.$, b);
            if (c != null && c.mr == this.mr && c.preferredCategoryMode(c.mr) == 2) {
                a++;
            }
        }
        return -1;
    }
}
RadialBase.$t = markType(RadialBase, 'RadialBase', MarkerSeries.$, [IHasCategoryModePreference_$type]);
Type.dep(DependencyProperty, PropertyMetadata, RadialBase, 'raisePropertyChanged', ['AngleAxis:mr:nd', [CategoryAngleAxis.$, null], 'ClipSeriesToBounds:m2:ne', [0, false], 'ValueAxis:mt:nf', [NumericRadiusAxis.$, null]]);
export class RadialBaseView extends MarkerSeriesView {
    constructor(a) {
        super(a);
        this.co = null;
        this.cn = null;
        this.cp = null;
        this.cq = 0;
        this.cr = null;
        this.cn = a;
        this.cp = new Pool$1(Marker.$);
        this.cf(this.cp);
    }
    cc(a) {
        this.cp.c(a);
    }
}
RadialBaseView.$t = markType(RadialBaseView, 'RadialBaseView', MarkerSeriesView.$);
