/*
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 {
        bc() {
            return new RadialPieSeries();
        }
        get_e1() {
            return true;
        }
        get_ez() {
            return true;
        }
        iq() {
            if (!isNaN_(this.ip)) {
                return super.iq();
            }
            return Defaults.h;
        }
        cd() {
            return new RadialPieSeriesView(this);
        }
        o2(a) {
            super.o2(a);
            this.yb = a;
        }
        constructor() {
            super();
            this.ab = RadialPieSeries.$;
        }
        preferredCategoryMode(a) {
            return a != null && a == this.vk ? 2 : 0;
        }
        nk(a, b) {
            super.nk(a, b);
            let c = b;
            if (a && c.c4 != null) {
                c.c4.count = 0;
            }
        }
        h1() {
            return this.vk.k4(this.cg.by, this.cg.bx, this.getEffectiveViewport1(this.cg));
        }
        get_dv() {
            return true;
        }
        wq(a, b) {
            super.wq(a, b);
            let c = b;
            let d = b.by;
            let e = b.bx;
            let f = this.getEffectiveViewport1(b);
            let g = this.tq(b);
            let h = this.vm.k1(e, d, f, g);
            let i = a.f;
            let j = this.vm;
            let k = Math.max(0, 0.5 * j.nn);
            let l = k;
            l = Math.max(l, h.minLength);
            let m = this.vk.k4(d, e, f);
            let n = { $type: Point_$type, x: 0.5, y: 0.5 };
            let o = this.yc;
            let p = this.yd;
            let q = (o > 0 && p > 0);
            let r = this.w4.count;
            this.vt.a2(this, this.wa(), runOn(this, this.vh), this.wd(b), this.we(b));
            this.vt.r = this.yc;
            this.vt.s = this.yd;
            this.vt.k = this.yc;
            this.vt.l = this.yd;
            let s = false;
            let t = this.vt.b;
            if (t != null) {
                s = true;
            }
            let u = this.vk;
            let v = new ScalerParams(1, b.by, b.bx, u.ch);
            v.c = this.getEffectiveViewport();
            let w = 0;
            for (let x = 0; x < i.count; ++x) {
                let y = c.c4.item(x);
                let z = i._inner[x][0];
                let aa = Math.min(i._inner[x][2], h.maxLength);
                if (s) {
                    this.xs(i, x, r, u, v, b.q);
                }
                let ab = this.vt.k;
                let ac = this.vt.l;
                q = (ab > 0 && ac > 0);
                let ad = null;
                if (q) {
                    ad = this.yi(d, e, z - (m * 0.5), z + (m * 0.5), l, aa, n, ab, ac);
                }
                else {
                    ad = this.yj(d, e, z - (m * 0.5), z + (m * 0.5), l, aa, n);
                }
                y.an = ad;
                this.vt.ad(y, false, false, false, false);
                let ae = i._inner[x][2];
                if (ae > w) {
                    w = ae;
                }
            }
            c.cx = ViewportUtils.d(w, d, e);
            c.cy = { $type: Point_$type, x: ViewportUtils.c(n.x, d, e), y: ViewportUtils.f(n.y, d, e) };
            c.c4.count = i.count;
            c.c9();
        }
        yj(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;
        }
        yi(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.yj(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;
        }
        pa(a, b, c, d) {
            super.pa(a, b, c, d);
            switch (b) {
                case RadialPieSeries.$$p[0]:
                case RadialPieSeries.$$p[1]:
                    this.o4();
                    break;
            }
        }
    }
    RadialPieSeries.$t = /*@__PURE__*/ markType(RadialPieSeries, 'RadialPieSeries', AnchoredRadialSeries.$);
    RadialPieSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, RadialPieSeries, 'raisePropertyChanged', ['RadiusX:yc:yg', [1, 2], 'RadiusY:yd:yh', [1, 2]]);
    return RadialPieSeries;
})();
/**
 * @hidden
 */
export let RadialPieSeriesView = /*@__PURE__*/ (() => {
    class RadialPieSeriesView extends AnchoredRadialSeriesView {
        constructor(a) {
            super(a);
            this.c3 = null;
            this.c4 = null;
            this.c5 = null;
            this.da = new Path();
            this.c3 = a;
            this.c4 = ((() => {
                let $ret = new Pool$1(Path.$);
                $ret.create = runOn(this, this.db);
                $ret.activate = runOn(this, this.c6);
                $ret.disactivate = runOn(this, this.c8);
                $ret.destroy = runOn(this, this.c7);
                return $ret;
            })());
        }
        au() {
            super.au();
            this.c5 = new List$1(Path.$, 0);
            if (!this.q) {
                this.cu.uc = Defaults.c;
                this.cu.iv = Defaults.i;
            }
        }
        db() {
            let a = ((() => {
                let $ret = new Path();
                $ret.dataContext = ((() => {
                    let $ret = new DataContext();
                    $ret.series = this.e;
                    return $ret;
                })());
                return $ret;
            })());
            this.c5.add(a);
            a._visibility = 1;
            return a;
        }
        c6(a) {
            a._visibility = 0;
        }
        c8(a) {
            a._visibility = 1;
        }
        c7(a) {
            this.c5.remove(a);
        }
        bg(a, b) {
            super.bg(a, b);
            let c = a;
        }
        ac(a) {
            return this.c5._inner[a];
        }
        ab(a) {
            let b = this.c5._inner[a];
            this.da._visibility = b._visibility;
            this.da.an = b.an;
            let c = this.bs(a);
            this.da._fill = c;
            this.da._stroke = c;
            this.da.ad = this.e.hl;
            return this.da;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                for (let c = 0; c < this.c5.count; c++) {
                    let d = this.aa(c, b);
                    a.t(d);
                }
            }
        }
        c9() {
            this.as();
        }
        an(a) {
            super.an(a);
            let b = 0;
            for (let c of fromEnum(this.c4.a)) {
                this.e.a5.exportPathData(a, c, "slice" + b, ["Main", "Fill"]);
                b++;
            }
        }
    }
    RadialPieSeriesView.$t = /*@__PURE__*/ markType(RadialPieSeriesView, 'RadialPieSeriesView', AnchoredRadialSeriesView.$);
    return RadialPieSeriesView;
})();
