/*
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 { AnchoredRadialSeries } from "./AnchoredRadialSeries";
import { DependencyProperty } from "igniteui-angular-core";
import { Defaults } from "./Defaults";
import { Point_$type, runOn, markType, markDep, fromEnum } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-angular-core";
import { ViewportUtils } from "./ViewportUtils";
import { SliceCoords } from "./SliceCoords";
import { PathFigure } from "igniteui-angular-core";
import { LineSegment } from "igniteui-angular-core";
import { ArcSegment } from "igniteui-angular-core";
import { Size } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
import { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView";
import { DataContext } from "igniteui-angular-core";
/**
 * @hidden
 */
var RadialPieSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialPieSeries, _super);
    function RadialPieSeries() {
        var _this = _super.call(this) || this;
        _this.ab = RadialPieSeries.$;
        return _this;
    }
    RadialPieSeries.prototype.get_d4 = function () {
        return true;
    };
    RadialPieSeries.prototype.get_d2 = function () {
        return true;
    };
    RadialPieSeries.prototype.gu = function () {
        if (!isNaN_(this.gt)) {
            return _super.prototype.gu.call(this);
        }
        return Defaults.h;
    };
    RadialPieSeries.prototype.bx = function () {
        return new RadialPieSeriesView(this);
    };
    RadialPieSeries.prototype.ly = function (a) {
        _super.prototype.ly.call(this, a);
        this.t6 = a;
    };
    RadialPieSeries.prototype.preferredCategoryMode = function (a) {
        return a != null && a == this.rk ? 2 : 0;
    };
    RadialPieSeries.prototype.kx = function (a, b) {
        _super.prototype.kx.call(this, a, b);
        var c = b;
        if (a && c.c1 != null) {
            c.c1.count = 0;
        }
    };
    RadialPieSeries.prototype.ga = function () {
        return this.rk.k3(this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
    };
    RadialPieSeries.prototype.get_c2 = function () {
        return true;
    };
    RadialPieSeries.prototype.sp = function (a, b) {
        _super.prototype.sp.call(this, a, b);
        var c = b;
        var d = b.bv;
        var e = b.bu;
        var f = this.getEffectiveViewport1(b);
        var g = this.pq(b);
        var h = this.rr.kz(e, d, f, g);
        var i = a.f;
        var j = this.rr;
        var k = Math.max(0, 0.5 * j.nl);
        var l = k;
        l = Math.max(l, h.minLength);
        var m = this.rk.k3(d, e, f);
        var n = { $type: Point_$type, x: 0.5, y: 0.5 };
        var o = this.t7;
        var p = this.t8;
        var q = (o > 0 && p > 0);
        var r = this.s3.count;
        this.ry.a0(this, this.sa(), runOn(this, this.rh), this.sc(b), this.sd(b));
        this.ry.r = this.t7;
        this.ry.s = this.t8;
        this.ry.k = this.t7;
        this.ry.l = this.t8;
        var s = false;
        var t = this.ry.b;
        if (t != null) {
            s = true;
        }
        var u = this.rk;
        var v = new ScalerParams(1, b.bv, b.bu, u.cg);
        v.c = this.getEffectiveViewport();
        var w = 0;
        for (var x = 0; x < i.count; ++x) {
            var y = c.c1.item(x);
            var z = i._inner[x][0];
            var aa = Math.min(i._inner[x][2], h.maxLength);
            if (s) {
                this.to(i, x, r, u, v, b.q);
            }
            var ab = this.ry.k;
            var ac = this.ry.l;
            q = (ab > 0 && ac > 0);
            var ad = null;
            if (q) {
                ad = this.ud(d, e, z - (m * 0.5), z + (m * 0.5), l, aa, n, ab, ac);
            }
            else {
                ad = this.ue(d, e, z - (m * 0.5), z + (m * 0.5), l, aa, n);
            }
            y.ak = ad;
            this.ry.ad(y, false, false, false, false);
            var ae = i._inner[x][2];
            if (ae > w) {
                w = ae;
            }
        }
        c.cu = ViewportUtils.d(w, d, e);
        c.cv = { $type: Point_$type, x: ViewportUtils.c(n.x, d, e), y: ViewportUtils.f(n.y, d, e) };
        c.c1.count = i.count;
        c.c6();
    };
    RadialPieSeries.prototype.ue = function (a, b, c, d, e, f, g) {
        var h = SliceCoords.b(a, b, c, d, e, f, g);
        var i = new PathFigure();
        i._startPoint = h.d;
        i._isClosed = true;
        i._segments.add(((function () {
            var $ret = new LineSegment(1);
            $ret.c = h.f;
            return $ret;
        })()));
        i._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.e = h.h;
            $ret.f = h.n;
            $ret.d = 1;
            $ret.b = h.c;
            return $ret;
        })()));
        i._segments.add(((function () {
            var $ret = new LineSegment(1);
            $ret.c = h.j;
            return $ret;
        })()));
        i._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.e = h.d;
            $ret.f = h.m;
            $ret.d = 0;
            $ret.b = h.c;
            return $ret;
        })()));
        var j = new PathGeometry();
        j.c.add(i);
        return j;
    };
    RadialPieSeries.prototype.ud = function (a, b, c, d, e, f, g, h, i) {
        var j = SliceCoords.a(a, b, c, d, e, f, g, h, i);
        if (j == null) {
            return this.ue(a, b, c, d, e, f, g);
        }
        var k = new PathFigure();
        k._startPoint = j.d;
        k._isClosed = true;
        var l = ((c + ((d - c) * 0.5)) * 180 / Math.PI) + 90;
        var m = new Size(1, j.l.width * (e / f), j.l.height * (e / f));
        k._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.e = j.e;
            $ret.f = m;
            $ret.c = l;
            $ret.d = 1;
            $ret.b = false;
            return $ret;
        })()));
        k._segments.add(((function () {
            var $ret = new LineSegment(1);
            $ret.c = j.f;
            return $ret;
        })()));
        k._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.e = j.g;
            $ret.f = j.l;
            $ret.c = l;
            $ret.d = 1;
            $ret.b = false;
            return $ret;
        })()));
        k._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.e = j.h;
            $ret.f = j.n;
            $ret.d = 1;
            $ret.b = j.c;
            return $ret;
        })()));
        k._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.e = j.i;
            $ret.f = j.l;
            $ret.c = l;
            $ret.d = 1;
            $ret.b = false;
            return $ret;
        })()));
        k._segments.add(((function () {
            var $ret = new LineSegment(1);
            $ret.c = j.j;
            return $ret;
        })()));
        k._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.e = j.k;
            $ret.f = m;
            $ret.c = l;
            $ret.d = 1;
            $ret.b = false;
            return $ret;
        })()));
        k._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.e = j.d;
            $ret.f = j.m;
            $ret.d = 0;
            $ret.b = j.c;
            return $ret;
        })()));
        var n = new PathGeometry();
        n.c.add(k);
        return n;
    };
    RadialPieSeries.prototype.l3 = function (a, b, c, d) {
        _super.prototype.l3.call(this, a, b, c, d);
        switch (b) {
            case RadialPieSeries.$$p[0]:
            case RadialPieSeries.$$p[1]:
                this.l0();
                break;
        }
    };
    RadialPieSeries.$t = markType(RadialPieSeries, 'RadialPieSeries', AnchoredRadialSeries.$);
    RadialPieSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RadialPieSeries, 'raisePropertyChanged', ['RadiusX:t7:ub', [1, 2], 'RadiusY:t8:uc', [1, 2]]);
    return RadialPieSeries;
}(AnchoredRadialSeries));
export { RadialPieSeries };
/**
 * @hidden
 */
var RadialPieSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialPieSeriesView, _super);
    function RadialPieSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.c0 = null;
        _this.c1 = null;
        _this.c2 = null;
        _this.c7 = new Path();
        _this.c0 = a;
        _this.c1 = ((function () {
            var $ret = new Pool$1(Path.$);
            $ret.create = runOn(_this, _this.c8);
            $ret.activate = runOn(_this, _this.c3);
            $ret.disactivate = runOn(_this, _this.c5);
            $ret.destroy = runOn(_this, _this.c4);
            return $ret;
        })());
        return _this;
    }
    RadialPieSeriesView.prototype.as = function () {
        _super.prototype.as.call(this);
        this.c2 = new List$1(Path.$, 0);
        if (!this.q) {
            this.cr.qc = Defaults.c;
            this.cr.gz = Defaults.i;
        }
    };
    RadialPieSeriesView.prototype.c8 = function () {
        var _this = this;
        var a = ((function () {
            var $ret = new Path();
            $ret.dataContext = ((function () {
                var $ret = new DataContext();
                $ret.series = _this.e;
                return $ret;
            })());
            return $ret;
        })());
        this.c2.add(a);
        a._visibility = 1;
        return a;
    };
    RadialPieSeriesView.prototype.c3 = function (a) {
        a._visibility = 0;
    };
    RadialPieSeriesView.prototype.c5 = function (a) {
        a._visibility = 1;
    };
    RadialPieSeriesView.prototype.c4 = function (a) {
        this.c2.remove(a);
    };
    RadialPieSeriesView.prototype.be = function (a, b) {
        _super.prototype.be.call(this, a, b);
        var c = a;
    };
    RadialPieSeriesView.prototype.ac = function (a) {
        return this.c2._inner[a];
    };
    RadialPieSeriesView.prototype.ab = function (a) {
        var b = this.c2._inner[a];
        this.c7._visibility = b._visibility;
        this.c7.ak = b.ak;
        var c = this.bp(a);
        this.c7._fill = c;
        this.c7._stroke = c;
        this.c7.ac = this.e.fu;
        return this.c7;
    };
    RadialPieSeriesView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (a.d) {
            for (var c = 0; c < this.c2.count; c++) {
                var d = this.aa(c, b);
                a.s(d);
            }
        }
    };
    RadialPieSeriesView.prototype.c6 = function () {
        this.aq();
    };
    RadialPieSeriesView.prototype.al = function (a) {
        var e_1, _a;
        _super.prototype.al.call(this, a);
        var b = 0;
        try {
            for (var _b = __values(fromEnum(this.c1.a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                this.e.a8.exportPathData(a, c, "slice" + b, ["Main", "Fill"]);
                b++;
            }
        }
        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;
            }
        }
    };
    RadialPieSeriesView.$t = markType(RadialPieSeriesView, 'RadialPieSeriesView', AnchoredRadialSeriesView.$);
    return RadialPieSeriesView;
}(AnchoredRadialSeriesView));
export { RadialPieSeriesView };
