/*
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 * as tslib_1 from "tslib";
import { Base, markType, runOn, 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 } 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 { 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";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { PropertyMetadata } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
/**
 * @hidden
 */
var RadialBucketCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(RadialBucketCalculator, _super);
    function RadialBucketCalculator(a) {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.c = 0;
        _this.d = 0;
        _this.b = 0;
        _this.a = a;
        return _this;
    }
    RadialBucketCalculator.prototype.getBucket = function (a) {
        throw new NotImplementedException(0);
    };
    RadialBucketCalculator.prototype.getBucketWithoutUnknowns = function (a) {
        return this.getBucket(a);
    };
    RadialBucketCalculator.prototype.getErrorBucket = function (a, b) {
        return NaN;
    };
    RadialBucketCalculator.prototype.getBucketInfo = function (a, b, c, d) {
        a = this.c;
        b = this.d;
        c = this.b;
        d = this.a.cn.eu;
        return {
            p0: a,
            p1: b,
            p2: c,
            p3: d
        };
    };
    RadialBucketCalculator.prototype.e = function (a) {
        var b = this.a.bs;
        var c = this.a.br;
        var d = this.a.cn.nd;
        if (b.isEmpty || c.isEmpty || d == null || this.a.cn.bz == null || this.a.cn.bz.count == 0) {
            this.b = 0;
            return;
        }
        var e = Math.floor(d.ll(c, b));
        var f = Math.ceil(d.lk(c, b));
        if (d.ca) {
            f = Math.ceil(d.ll(c, b));
            e = Math.floor(d.lk(c, b));
        }
        if (f < e) {
            f = d.j7 + f;
        }
        var g = this.a.cn.nf;
        var h = g != null ? g.lr : 0.75;
        var i = Math.min(c.width, c.height) * 0.5 * (h) * 2 * Math.PI;
        var 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));
    };
    RadialBucketCalculator.prototype.cacheValues = function () {
    };
    RadialBucketCalculator.prototype.unCacheValues = function () {
    };
    RadialBucketCalculator.$t = markType(RadialBucketCalculator, 'RadialBucketCalculator', Base.$, [IBucketizer_$type]);
    return RadialBucketCalculator;
}(Base));
export { RadialBucketCalculator };
/**
 * @hidden
 */
var RadialBase = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(RadialBase, _super);
    function RadialBase() {
        var _this = _super.call(this) || this;
        _this.nl = null;
        _this.nj = new RadialFrame(3);
        _this.nk = new RadialFrame(3);
        _this.ni = new RadialFrame(3);
        _this.ng = null;
        _this.nl = new SeriesRenderer$2(RadialFrame.$, RadialBaseView.$, 1, runOn(_this, _this.nw), runOn(_this, _this.nx), runOn(_this, _this.ca), runOn(_this, _this.jt), runOn(_this, _this.nv), function (a) { return _this.nh.co.e(_this.eu); });
        return _this;
    }
    RadialBase.prototype.i2 = function (a) {
        _super.prototype.i2.call(this, a);
        this.nh = a;
    };
    RadialBase.prototype.nv = function () {
        if (this.bt.g) {
            this.bt.t();
        }
    };
    Object.defineProperty(RadialBase.prototype, "categoryAxis", {
        get: function () {
            return this.nd;
        },
        enumerable: true,
        configurable: true
    });
    RadialBase.prototype.ap = function () {
        return this.nd;
    };
    RadialBase.prototype.np = function (a) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var b = this.nd;
        var c = new ScalerParams(1, this.bs.n2, this.l8, b.ca);
        c.c = this.getEffectiveViewport1(this.bi);
        var d = this.nf;
        var e = new ScalerParams(1, this.bs.n2, this.l8, d.ca);
        e.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.ma.cc(function (f) {
            if (f._visibility == 0) {
                var g = new SeriesPointOfInterest();
                var h = f.n;
                var i = f.o;
                if (h < _this.l8.left || h > _this.l8.right || i < _this.l8.top || i > _this.l8.bottom) {
                    return;
                }
                g.b = b.d1(h, c);
                g.c = d.d1(i, e);
                g.d = b.fl(f.ak);
                g.a = f.content;
                a.add(g);
            }
        });
        return true;
    };
    RadialBase.prototype.get_c2 = function () {
        return true;
    };
    RadialBase.prototype.ag = function () {
        return [this.nd, this.nf];
    };
    RadialBase.prototype.j1 = function (a, b) {
        this.nh.co.e(this.eu);
        this.jl(false);
    };
    RadialBase.prototype.j0 = function (a, b) {
        this.nh.co.e(this.eu);
        this.jl(false);
    };
    RadialBase.prototype.i7 = function (a, b, c, d) {
        _super.prototype.i7.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (c != null && d == null) {
                    if (this.nd != null) {
                        this.nd.bx(this);
                    }
                    if (this.nf != null) {
                        this.nf.bx(this);
                    }
                }
                if (c == null && d != null) {
                    if (this.nd != null) {
                        this.nd.ck(this);
                    }
                    if (this.nf != null) {
                        this.nf.ck(this);
                    }
                }
                this.nh.co.e(this.eu);
                this.jl(false);
                break;
            case RadialBase.$$p[0]:
                if (this.nd != null && this.nf != null) {
                    this.ng = new RadialAxes(this.nf, this.nd);
                }
                if (c != null) {
                    c.bx(this);
                }
                if (d != null) {
                    d.ck(this);
                }
                this.nh.co.e(this.eu);
                this.jl(false);
                break;
            case RadialBase.$$p[2]:
                if (this.nd != null && this.nf != null) {
                    this.ng = new RadialAxes(this.nf, this.nd);
                }
                if (c != null) {
                    c.bx(this);
                }
                if (d != null) {
                    d.ck(this);
                }
                this.nh.co.e(this.eu);
                if (this.nf == null || !this.nf.cn()) {
                    this.jl(false);
                }
                break;
            case "SyncLink":
                if (this.bn != null && this.bs != null) {
                    this.nh.co.e(this.eu);
                    this.jl(false);
                }
                break;
            case "TransitionProgress":
                this.nk.c(this.ez, this.nj, this.ni);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.ez == 1) {
                    this.nx(this.ni, this.nh);
                }
                else {
                    this.nx(this.nk, this.nh);
                }
                if (this.bs != null) {
                    this.bs.ko(this);
                }
                break;
            case RadialBase.$$p[1]:
                this.jl(false);
                this.it();
                break;
            case "VisibilityProxy":
                if (EnumUtil.getEnumValue(Visibility_$type, c) != 0 && EnumUtil.getEnumValue(Visibility_$type, d) == 0) {
                    this.nh.co.e(this.eu);
                }
                break;
        }
    };
    RadialBase.prototype.nn = function (a) {
        if (typeCast(NumericRadiusAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    RadialBase.prototype.nm = function (a) {
        if (typeCast(CategoryAngleAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    RadialBase.prototype.fp = function (a) {
        var b = this.e8(a);
        return b >= 0 && this.bz != null && b < this.bz.count ? this.bz.item(b) : null;
    };
    RadialBase.prototype.nq = function (a) {
        var b = this.bi.bs;
        var c = this.bi.br;
        if (this.nd != null && !b.isEmpty && !c.isEmpty && this.ng != null) {
            var d = this.ng.c(a);
            if (d < 0) {
                d += Math.PI * 2;
            }
            if (d > Math.PI * 2) {
                d -= Math.PI * 2;
            }
            return d;
        }
        return NaN;
    };
    RadialBase.prototype.eb = function (a) {
        var b = this.bi.bs;
        var c = this.bi.br;
        var d = -1;
        if (this.nd != null && !b.isEmpty && !c.isEmpty && this.ng != null) {
            var e = this.ng.c(a);
            if (e < 0) {
                e += Math.PI * 2;
            }
            if (e > Math.PI * 2) {
                e -= Math.PI * 2;
            }
            var f = this.nd.getUnscaledAngle(e);
            if (this.nd.categoryMode != 0) {
                f -= 0.5;
            }
            d = f;
        }
        return d;
    };
    RadialBase.prototype.e8 = function (a) {
        var b = truncate(Math.round(this.eb(a)));
        if (this.bz != null && b == this.bz.count) {
            b = 0;
        }
        return b;
    };
    RadialBase.prototype.c9 = function (a) {
        return false;
    };
    RadialBase.prototype.ik = function () {
        _super.prototype.ik.call(this);
        if (this.nd != null) {
            this.nd.hb(false);
        }
        if (this.nf != null) {
            this.nf.hb(false);
        }
    };
    RadialBase.prototype.dw = function (a, b, c) {
        var d = true;
        var e = c;
        if (!_super.prototype.dw.call(this, a, b, c) || !c.l() || b.isEmpty || a.isEmpty || this.nd == null || this.nd.itemsSource == null || this.nf == null || this.ng == null || this.bz == null || this.nd.bh == null || this.nf.bh == null || this.nf.kc == this.nf.kb) {
            e.co.b = 0;
            d = false;
        }
        return d;
    };
    RadialBase.prototype.jm = function (a) {
        var b;
        var c;
        var d = this.getViewInfo(c, b);
        c = d.p0;
        b = d.p1;
        if (!this.dw(c, b, this.bi)) {
            this.h3(true, this.bi);
            return;
        }
        var e = new SeriesRenderingArguments(this, c, b, a, this.de);
        var f = this.nl.g(e, this.nj, this.ni, this.nk, this.nh);
        this.nj = f.p1;
        this.ni = f.p2;
        this.nk = f.p3;
    };
    RadialBase.prototype.nr = function () {
        var e_1, _a;
        var a = 0;
        try {
            for (var _b = tslib_1.__values(fromEnum(this.bs.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (b == this) {
                    return a;
                }
                var c = typeCast(RadialBase.$, b);
                if (c != null && c.nd == this.nd && c.preferredCategoryMode(c.nd) == 2) {
                    a++;
                }
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        return -1;
    };
    RadialBase.$t = markType(RadialBase, 'RadialBase', MarkerSeries.$, [IHasCategoryModePreference_$type]);
    RadialBase.$$p = markDep(DependencyProperty, PropertyMetadata, RadialBase, 'raisePropertyChanged', ['AngleAxis:nd:ny', [CategoryAngleAxis.$, null], 'ClipSeriesToBounds:no:nz', [0, false], 'ValueAxis:nf:n0', [NumericRadiusAxis.$, null]]);
    return RadialBase;
}(MarkerSeries));
export { RadialBase };
/**
 * @hidden
 */
var RadialBaseView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(RadialBaseView, _super);
    function RadialBaseView(a) {
        var _this = _super.call(this, a) || this;
        _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);
        return _this;
    }
    RadialBaseView.prototype.cc = function (a) {
        this.cp.c(a);
    };
    RadialBaseView.$t = markType(RadialBaseView, 'RadialBaseView', MarkerSeriesView.$);
    return RadialBaseView;
}(MarkerSeriesView));
export { RadialBaseView };
//# sourceMappingURL=RadialBucketCalculator_combined.js.map
