/*
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-react-core";
import { Defaults } from "./Defaults";
import { Point_$type, runOn, markType, markDep, fromEnum } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-react-core";
import { ViewportUtils } from "./ViewportUtils";
import { SliceCoords } from "./SliceCoords";
import { PathFigure } from "igniteui-react-core";
import { LineSegment } from "igniteui-react-core";
import { ArcSegment } from "igniteui-react-core";
import { Size } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView";
import { DataContext } from "igniteui-react-core";
/**
 * @hidden
 */
export let RadialPieSeries = /*@__PURE__*/ (() => {
    class RadialPieSeries extends AnchoredRadialSeries {
        get_d7() {
            return true;
        }
        get_d5() {
            return true;
        }
        gz() {
            if (!isNaN_(this.gy)) {
                return super.gz();
            }
            return Defaults.h;
        }
        by() {
            return new RadialPieSeriesView(this);
        }
        l4(a) {
            super.l4(a);
            this.uf = a;
        }
        constructor() {
            super();
            this.ab = RadialPieSeries.$;
        }
        preferredCategoryMode(a) {
            return a != null && a == this.rt ? 2 : 0;
        }
        k2(a, b) {
            super.k2(a, b);
            let c = b;
            if (a && c.c1 != null) {
                c.c1.count = 0;
            }
        }
        ge() {
            return this.rt.k4(this.b1.bv, this.b1.bu, this.getEffectiveViewport1(this.b1));
        }
        get_c3() {
            return true;
        }
        sy(a, b) {
            super.sy(a, b);
            let c = b;
            let d = b.bv;
            let e = b.bu;
            let f = this.getEffectiveViewport1(b);
            let g = this.pz(b);
            let h = this.r0.k1(e, d, f, g);
            let i = a.f;
            let j = this.r0;
            let k = Math.max(0, 0.5 * j.nn);
            let l = k;
            l = Math.max(l, h.minLength);
            let m = this.rt.k4(d, e, f);
            let n = { $type: Point_$type, x: 0.5, y: 0.5 };
            let o = this.ug;
            let p = this.uh;
            let q = (o > 0 && p > 0);
            let r = this.tc.count;
            this.r7.a2(this, this.sj(), runOn(this, this.rq), this.sl(b), this.sm(b));
            this.r7.r = this.ug;
            this.r7.s = this.uh;
            this.r7.k = this.ug;
            this.r7.l = this.uh;
            let s = false;
            let t = this.r7.b;
            if (t != null) {
                s = true;
            }
            let u = this.rt;
            let v = new ScalerParams(1, b.bv, b.bu, u.ch);
            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.tx(i, x, r, u, v, b.q);
                }
                let ab = this.r7.k;
                let ac = this.r7.l;
                q = (ab > 0 && ac > 0);
                let ad = null;
                if (q) {
                    ad = this.um(d, e, z - (m * 0.5), z + (m * 0.5), l, aa, n, ab, ac);
                }
                else {
                    ad = this.un(d, e, z - (m * 0.5), z + (m * 0.5), l, aa, n);
                }
                y.an = ad;
                this.r7.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();
        }
        un(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;
        }
        um(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.un(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;
        }
        l9(a, b, c, d) {
            super.l9(a, b, c, d);
            switch (b) {
                case RadialPieSeries.$$p[0]:
                case RadialPieSeries.$$p[1]:
                    this.l6();
                    break;
            }
        }
    }
    RadialPieSeries.$t = /*@__PURE__*/ markType(RadialPieSeries, 'RadialPieSeries', AnchoredRadialSeries.$);
    RadialPieSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, RadialPieSeries, 'raisePropertyChanged', ['RadiusX:ug:uk', [1, 2], 'RadiusY:uh:ul', [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.ql = Defaults.c;
                this.cr.g4 = 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.an = b.an;
            let c = this.bp(a);
            this.c7._fill = c;
            this.c7._stroke = c;
            this.c7.ad = this.e.fy;
            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.a9.exportPathData(a, c, "slice" + b, ["Main", "Fill"]);
                b++;
            }
        }
    }
    RadialPieSeriesView.$t = /*@__PURE__*/ markType(RadialPieSeriesView, 'RadialPieSeriesView', AnchoredRadialSeriesView.$);
    return RadialPieSeriesView;
})();
