/*
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 { AnchoredRadialSeries } from "./AnchoredRadialSeries";
import { DependencyProperty } from "igniteui-angular-core";
import { Point_$type, markType, markDep, runOn, 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 { 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 { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView";
import { DataContext } from "igniteui-angular-core";
/**
 * @hidden
 */
var RadialPieSeries = /** @class */ (function (_super) {
    tslib_1.__extends(RadialPieSeries, _super);
    function RadialPieSeries() {
        var _this = _super.call(this) || this;
        _this.ab = RadialPieSeries.$;
        return _this;
    }
    RadialPieSeries.prototype.bf = function () {
        return new RadialPieSeriesView(this);
    };
    RadialPieSeries.prototype.iu = function (a) {
        _super.prototype.iu.call(this, a);
        this.oq = a;
    };
    RadialPieSeries.prototype.preferredCategoryMode = function (a) {
        return a != null && a == this.m0 ? 2 : 0;
    };
    RadialPieSeries.prototype.hv = function (a, b) {
        _super.prototype.hv.call(this, a, b);
        var c = b;
        if (a && c.cx != null) {
            c.cx.count = 0;
        }
    };
    RadialPieSeries.prototype.eg = function () {
        return this.m0.jr(this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi));
    };
    RadialPieSeries.prototype.nl = function (a, b) {
        _super.prototype.nl.call(this, a, b);
        var c = b;
        var d = b.bs;
        var e = b.br;
        var f = this.getEffectiveViewport1(b);
        var g = this.lq(b);
        var h = this.m2.jg(e, d, f, g);
        var i = a.f;
        var j = this.m2;
        var k = Math.max(0, 0.5 * j.li);
        var l = k;
        l = Math.max(l, h.minLength);
        var m = this.m0.jr(d, e, f);
        var n = { $type: Point_$type, x: 0.5, y: 0.5 };
        var o = this.or;
        var p = this.os;
        var q = (o > 0 && p > 0);
        var r = 0;
        for (var s = 0; s < i.count; ++s) {
            var t = c.cx.item(s);
            var u = i._inner[s][0];
            var v = Math.min(i._inner[s][2], h.maxLength);
            var w = null;
            if (q) {
                w = this.ox(d, e, u - (m * 0.5), u + (m * 0.5), l, v, n, o, p);
            }
            else {
                w = this.oy(d, e, u - (m * 0.5), u + (m * 0.5), l, v, n);
            }
            t.ak = w;
            var x = i._inner[s][2];
            if (x > r) {
                r = x;
            }
        }
        c.cq = ViewportUtils.d(r, d, e);
        c.cr = { $type: Point_$type, x: ViewportUtils.c(n.x, d, e), y: ViewportUtils.f(n.y, d, e) };
        c.cx.count = i.count;
        c.c2();
    };
    RadialPieSeries.prototype.oy = 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.ox = 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.oy(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.iz = function (a, b, c, d) {
        _super.prototype.iz.call(this, a, b, c, d);
        switch (b) {
            case RadialPieSeries.$$p[0]:
            case RadialPieSeries.$$p[1]:
                this.jd(false);
                break;
        }
    };
    RadialPieSeries.$t = markType(RadialPieSeries, 'RadialPieSeries', AnchoredRadialSeries.$);
    RadialPieSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RadialPieSeries, 'raisePropertyChanged', ['RadiusX:or:ov', [1, 2], 'RadiusY:os:ow', [1, 2]]);
    return RadialPieSeries;
}(AnchoredRadialSeries));
export { RadialPieSeries };
/**
 * @hidden
 */
var RadialPieSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(RadialPieSeriesView, _super);
    function RadialPieSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.cw = null;
        _this.cx = null;
        _this.cy = null;
        _this.cw = a;
        _this.cx = ((function () {
            var $ret = new Pool$1(Path.$);
            $ret.create = runOn(_this, _this.c3);
            $ret.activate = runOn(_this, _this.cz);
            $ret.disactivate = runOn(_this, _this.c1);
            $ret.destroy = runOn(_this, _this.c0);
            return $ret;
        })());
        return _this;
    }
    RadialPieSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        this.cy = new List$1(Path.$, 0);
        if (!this.n) {
            this.e.eu = 4;
            this.e.bj = 1;
        }
    };
    RadialPieSeriesView.prototype.c3 = 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.cy.add(a);
        a._visibility = 1;
        return a;
    };
    RadialPieSeriesView.prototype.cz = function (a) {
        a._visibility = 0;
    };
    RadialPieSeriesView.prototype.c1 = function (a) {
        a._visibility = 1;
    };
    RadialPieSeriesView.prototype.c0 = function (a) {
        this.cy.remove(a);
    };
    RadialPieSeriesView.prototype.bb = function (a, b) {
        _super.prototype.bb.call(this, a, b);
        var c = a;
        c._stroke = this.e.k4;
        c.ac = this.e.ey;
        c._fill = this.e.k3;
        c.ai = this.e.lb;
        c.ad = this.e.lc;
    };
    RadialPieSeriesView.prototype.bc = function (a, b) {
        _super.prototype.bc.call(this, a, b);
        var c = a;
        var d = this.bm(b);
        c._stroke = d;
        c.ac = this.e.ey;
        c._fill = d;
    };
    RadialPieSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d) {
            for (var c = 0; c < this.cy.count; c++) {
                var d = this.cy._inner[c];
                this.ba(d, c, b);
                a.s(d);
            }
        }
    };
    RadialPieSeriesView.prototype.c2 = function () {
        this.an();
    };
    RadialPieSeriesView.prototype.ai = function (a) {
        var e_1, _a;
        _super.prototype.ai.call(this, a);
        var b = 0;
        try {
            for (var _b = tslib_1.__values(fromEnum(this.cx.a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                this.e.a2.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 };
//# sourceMappingURL=RadialPieSeries_combined.js.map