/*
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 { 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
 */
export let RadialPieSeries = /*@__PURE__*/ (() => {
    class RadialPieSeries extends AnchoredRadialSeries {
        constructor() {
            super();
            this.ab = RadialPieSeries.$;
        }
        get_d5() {
            return true;
        }
        get_d3() {
            return true;
        }
        gw() {
            if (!isNaN_(this.gv)) {
                return super.gw();
            }
            return Defaults.h;
        }
        bx() {
            return new RadialPieSeriesView(this);
        }
        l2(a) {
            super.l2(a);
            this.ub = a;
        }
        preferredCategoryMode(a) {
            return a != null && a == this.rp ? 2 : 0;
        }
        k0(a, b) {
            super.k0(a, b);
            let c = b;
            if (a && c.c1 != null) {
                c.c1.count = 0;
            }
        }
        gc() {
            return this.rp.k3(this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
        }
        get_c2() {
            return true;
        }
        su(a, b) {
            super.su(a, b);
            let c = b;
            let d = b.bv;
            let e = b.bu;
            let f = this.getEffectiveViewport1(b);
            let g = this.pv(b);
            let h = this.rw.kz(e, d, f, g);
            let i = a.f;
            let j = this.rw;
            let k = Math.max(0, 0.5 * j.nl);
            let l = k;
            l = Math.max(l, h.minLength);
            let m = this.rp.k3(d, e, f);
            let n = { $type: Point_$type, x: 0.5, y: 0.5 };
            let o = this.uc;
            let p = this.ud;
            let q = (o > 0 && p > 0);
            let r = this.s8.count;
            this.r3.a0(this, this.sf(), runOn(this, this.rm), this.sh(b), this.si(b));
            this.r3.r = this.uc;
            this.r3.s = this.ud;
            this.r3.k = this.uc;
            this.r3.l = this.ud;
            let s = false;
            let t = this.r3.b;
            if (t != null) {
                s = true;
            }
            let u = this.rp;
            let v = new ScalerParams(1, b.bv, b.bu, u.cg);
            v.c = this.getEffectiveViewport();
            let w = 0;
            for (let x = 0; x < i.count; ++x) {
                let y = c.c1.item(x);
                let z = i._inner[x][0];
                let aa = Math.min(i._inner[x][2], h.maxLength);
                if (s) {
                    this.tt(i, x, r, u, v, b.q);
                }
                let ab = this.r3.k;
                let ac = this.r3.l;
                q = (ab > 0 && ac > 0);
                let ad = null;
                if (q) {
                    ad = this.ui(d, e, z - (m * 0.5), z + (m * 0.5), l, aa, n, ab, ac);
                }
                else {
                    ad = this.uj(d, e, z - (m * 0.5), z + (m * 0.5), l, aa, n);
                }
                y.ak = ad;
                this.r3.ad(y, false, false, false, false);
                let 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();
        }
        uj(a, b, c, d, e, f, g) {
            let h = SliceCoords.b(a, b, c, d, e, f, g);
            let i = new PathFigure();
            i._startPoint = h.d;
            i._isClosed = true;
            i._segments.add(((() => {
                let $ret = new LineSegment(1);
                $ret.c = h.f;
                return $ret;
            })()));
            i._segments.add(((() => {
                let $ret = new ArcSegment();
                $ret.e = h.h;
                $ret.f = h.n;
                $ret.d = 1;
                $ret.b = h.c;
                return $ret;
            })()));
            i._segments.add(((() => {
                let $ret = new LineSegment(1);
                $ret.c = h.j;
                return $ret;
            })()));
            i._segments.add(((() => {
                let $ret = new ArcSegment();
                $ret.e = h.d;
                $ret.f = h.m;
                $ret.d = 0;
                $ret.b = h.c;
                return $ret;
            })()));
            let j = new PathGeometry();
            j.c.add(i);
            return j;
        }
        ui(a, b, c, d, e, f, g, h, i) {
            let j = SliceCoords.a(a, b, c, d, e, f, g, h, i);
            if (j == null) {
                return this.uj(a, b, c, d, e, f, g);
            }
            let k = new PathFigure();
            k._startPoint = j.d;
            k._isClosed = true;
            let l = ((c + ((d - c) * 0.5)) * 180 / Math.PI) + 90;
            let m = new Size(1, j.l.width * (e / f), j.l.height * (e / f));
            k._segments.add(((() => {
                let $ret = new ArcSegment();
                $ret.e = j.e;
                $ret.f = m;
                $ret.c = l;
                $ret.d = 1;
                $ret.b = false;
                return $ret;
            })()));
            k._segments.add(((() => {
                let $ret = new LineSegment(1);
                $ret.c = j.f;
                return $ret;
            })()));
            k._segments.add(((() => {
                let $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(((() => {
                let $ret = new ArcSegment();
                $ret.e = j.h;
                $ret.f = j.n;
                $ret.d = 1;
                $ret.b = j.c;
                return $ret;
            })()));
            k._segments.add(((() => {
                let $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(((() => {
                let $ret = new LineSegment(1);
                $ret.c = j.j;
                return $ret;
            })()));
            k._segments.add(((() => {
                let $ret = new ArcSegment();
                $ret.e = j.k;
                $ret.f = m;
                $ret.c = l;
                $ret.d = 1;
                $ret.b = false;
                return $ret;
            })()));
            k._segments.add(((() => {
                let $ret = new ArcSegment();
                $ret.e = j.d;
                $ret.f = j.m;
                $ret.d = 0;
                $ret.b = j.c;
                return $ret;
            })()));
            let n = new PathGeometry();
            n.c.add(k);
            return n;
        }
        l7(a, b, c, d) {
            super.l7(a, b, c, d);
            switch (b) {
                case RadialPieSeries.$$p[0]:
                case RadialPieSeries.$$p[1]:
                    this.l4();
                    break;
            }
        }
    }
    RadialPieSeries.$t = markType(RadialPieSeries, 'RadialPieSeries', AnchoredRadialSeries.$);
    RadialPieSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RadialPieSeries, 'raisePropertyChanged', ['RadiusX:uc:ug', [1, 2], 'RadiusY:ud:uh', [1, 2]]);
    return RadialPieSeries;
})();
/**
 * @hidden
 */
export let RadialPieSeriesView = /*@__PURE__*/ (() => {
    class RadialPieSeriesView extends AnchoredRadialSeriesView {
        constructor(a) {
            super(a);
            this.c0 = null;
            this.c1 = null;
            this.c2 = null;
            this.c7 = new Path();
            this.c0 = a;
            this.c1 = ((() => {
                let $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;
            })());
        }
        as() {
            super.as();
            this.c2 = new List$1(Path.$, 0);
            if (!this.q) {
                this.cr.qh = Defaults.c;
                this.cr.g1 = Defaults.i;
            }
        }
        c8() {
            let a = ((() => {
                let $ret = new Path();
                $ret.dataContext = ((() => {
                    let $ret = new DataContext();
                    $ret.series = this.e;
                    return $ret;
                })());
                return $ret;
            })());
            this.c2.add(a);
            a._visibility = 1;
            return a;
        }
        c3(a) {
            a._visibility = 0;
        }
        c5(a) {
            a._visibility = 1;
        }
        c4(a) {
            this.c2.remove(a);
        }
        be(a, b) {
            super.be(a, b);
            let c = a;
        }
        ac(a) {
            return this.c2._inner[a];
        }
        ab(a) {
            let b = this.c2._inner[a];
            this.c7._visibility = b._visibility;
            this.c7.ak = b.ak;
            let c = this.bp(a);
            this.c7._fill = c;
            this.c7._stroke = c;
            this.c7.ac = this.e.fw;
            return this.c7;
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                for (let c = 0; c < this.c2.count; c++) {
                    let d = this.aa(c, b);
                    a.t(d);
                }
            }
        }
        c6() {
            this.aq();
        }
        al(a) {
            super.al(a);
            let b = 0;
            for (let c of fromEnum(this.c1.a)) {
                this.e.a8.exportPathData(a, c, "slice" + b, ["Main", "Fill"]);
                b++;
            }
        }
    }
    RadialPieSeriesView.$t = markType(RadialPieSeriesView, 'RadialPieSeriesView', AnchoredRadialSeriesView.$);
    return RadialPieSeriesView;
})();
