/*
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 { enumGetBox, Point_$type, runOn, typeCast, markType, markDep, fromEnum } from "igniteui-angular-core";
import { LegendEmptyValuesMode_$type } from "igniteui-angular-core";
import { Defaults } from "./Defaults";
import { Pool$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { RadialBaseView } from "./RadialBaseView";
import { ScalerParams } from "./ScalerParams";
import { ViewportUtils } from "./ViewportUtils";
import { SliceCoords } from "./SliceCoords";
import { Size } from "igniteui-angular-core";
import { GeometryUtil } from "igniteui-angular-core";
import { PathFigure } from "igniteui-angular-core";
import { PathGeometry } from "igniteui-angular-core";
import { LineSegment } from "igniteui-angular-core";
import { ArcSegment } from "igniteui-angular-core";
import { PieSliceCollisionGeometry } from "igniteui-angular-core";
import { MathUtil } from "igniteui-angular-core";
import { ProportionalCategoryAngleAxis } from "./ProportionalCategoryAngleAxis";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { DataContext } from "igniteui-angular-core";
import { ChartSelection } from "./ChartSelection";
import { CollisionRect } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { intDivide, isNaN_ } from "igniteui-angular-core";
import { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView";
/**
 * @hidden
 */
export let RadialPieSeries = /*@__PURE__*/ (() => {
    class RadialPieSeries extends AnchoredRadialSeries {
        constructor() {
            super();
            this.ad0 = null;
            this.ad7 = null;
            this.adx = 0;
            this.ad3 = false;
            this.ab = RadialPieSeries.$;
        }
        bk() {
            return new RadialPieSeries();
        }
        get_fo() {
            return true;
        }
        get_fm() {
            return true;
        }
        jn() {
            if (!isNaN_(this.jm)) {
                return super.jn();
            }
            return Defaults.h;
        }
        ct() {
            return new RadialPieSeriesView(this);
        }
        q7(a) {
            super.q7(a);
            this.adz = a;
        }
        get ad1() {
            return this.ad0;
        }
        set ad1(a) {
            if (this.ad0 != a) {
                let b = this.ad1;
                this.ad0 = a;
                this.raisePropertyChanged("LegendLabelColumn", b, this.ad1);
            }
        }
        get aea() {
            return this.ad7;
        }
        set aea(a) {
            if (this.ad7 != a) {
                let b = this.ad7;
                this.ad7 = a;
                this.raisePropertyChanged("LegendLabelMemberPath", b, this.ad7);
            }
        }
        get ady() {
            return this.adx;
        }
        set ady(a) {
            if (this.adx != a) {
                let b = this.adx;
                this.adx = a;
                this.raisePropertyChanged("LegendEmptyValuesMode", enumGetBox(LegendEmptyValuesMode_$type, b), enumGetBox(LegendEmptyValuesMode_$type, this.adx));
            }
        }
        get ad4() {
            return this.ad3;
        }
        set ad4(a) {
            if (this.ad3 != a) {
                let b = this.ad3;
                this.ad3 = a;
                this.raisePropertyChanged("UseInsetOutlines", b, this.ad3);
            }
        }
        preferredCategoryMode(a) {
            return a != null && a == this.y9 ? 2 : 0;
        }
        pb(a, b) {
            super.pb(a, b);
            let c = b;
            if (a && c.dj != null) {
                c.dj.count = 0;
            }
        }
        iy() {
            return this.y9.ou(this.cw.ca, this.cw.b9, this.getEffectiveViewport1(this.cw));
        }
        ar(a, b) {
            let c = new List$1(Rect.$, 0);
            let d = this.cw.ca;
            let e = this.cw.b9;
            let f = this.getEffectiveViewport1(this.cw);
            let g = this.wt(this.cw);
            let h = this.zf.or(e, d, f, g);
            let i = { $type: Point_$type, x: 0.5, y: 0.5 };
            let j = this.zf;
            let k = Math.max(0, 0.5 * j.sa);
            let l = k;
            l = Math.max(l, h.minLength);
            let m = this.y9.ou(d, e, f);
            let n = this.y9 != null && this.y9.dj;
            let o = this.zi;
            if (this.d4()) {
                o = this.zl;
            }
            {
                if (n) {
                    m = this.z8(a, d, e, f);
                }
                if (b < 0 || b > o.h.count - 1) {
                    return null;
                }
                let p = o.h._inner[b][0];
                let q = Math.min(o.h._inner[b][2], h.maxLength);
                return this.ad2(d, e, f, p - (m * 0.5), p + (m * 0.5), l, q, i);
            }
        }
        get_ef() {
            return true;
        }
        get_aco() {
            return true;
        }
        get_aci() {
            return true;
        }
        iq() {
            let a = super.iq();
            if (this.ad4 && !isNaN_(a)) {
                a = a * 2;
            }
            return a;
        }
        abk(a, b) {
            super.abk(a, b);
            let c = b;
            let d = b.ca;
            let e = b.b9;
            let f = this.getEffectiveViewport1(b);
            let g = this.wt(b);
            let h = this.zf.or(e, d, f, g);
            let i = a.h;
            let j = this.zf;
            let k = Math.max(0, 0.5 * j.sa);
            let l = k;
            l = Math.max(l, h.minLength);
            let m = this.y9.ou(d, e, f);
            let n = this.y9.dj;
            let o = { $type: Point_$type, x: 0.5, y: 0.5 };
            let p = this.ad5;
            let q = this.ad6;
            let r = (p > 0 && q > 0);
            let s = this.acg.count;
            this.zo.a2(this, this.z5(), runOn(this, this.yx), this.aae(b), this.aaf(b));
            this.zo.r = this.ad5;
            this.zo.s = this.ad6;
            this.zo.k = this.ad5;
            this.zo.l = this.ad6;
            this.zo.t = this.ad4 ? this.jt * 2 : this.jt;
            let t = false;
            let u = this.zo.b;
            if (u != null) {
                t = true;
            }
            let v = this.y9;
            let w = new ScalerParams(1, b.ca, b.b9, v.df);
            w.c = this.getEffectiveViewport();
            let x = 0;
            let y = 0;
            for (let z = 0; z < i.count; ++z) {
                let aa = i._inner[z][0];
                let ab = Math.min(i._inner[z][2], h.maxLength);
                let ac = i._inner[z][1];
                let ad = i._inner[z][2];
                let ae = i._inner[z][3];
                if (t) {
                    this.add(i, z, s, v, w, b.t);
                }
                if (n) {
                    if (isNaN_(aa) || isNaN_(ac) || isNaN_(ad)) {
                        continue;
                    }
                    let af = (b.da.c + z) * b.da.b;
                    if ((b.da.c + z) * b.da.b > this.y9.o6 - 1) {
                        if ((af) * b.da.b >= this.y9.o5) {
                            af = (af) - (intDivide((this.y9.o5), b.da.b));
                        }
                    }
                    m = ae;
                    if (isNaN_(m)) {
                        continue;
                    }
                }
                let ag = c.dj.item(x);
                x++;
                let ah = this.zo.k;
                let ai = this.zo.l;
                r = (ah > 0 && ai > 0);
                let aj = null;
                if (r) {
                    aj = this.aei(d, e, f, aa - (m * 0.5), aa + (m * 0.5), l, ab, o, ah, ai);
                }
                else {
                    aj = this.aej(d, e, f, aa - (m * 0.5), aa + (m * 0.5), l, ab, o);
                }
                ag.an = aj;
                this.zo.ad(ag, false, false, false, false);
                let ak = i._inner[z][2];
                if (ak > y) {
                    y = ak;
                }
            }
            c.dc = ViewportUtils.f(y, d, e);
            c.dd = { $type: Point_$type, x: ViewportUtils.e(o.x, d, e, f), y: ViewportUtils.i(o.y, d, e, f) };
            c.dj.count = x;
            c.dp();
        }
        aef(a, b, c, d, e, f, g) {
            if (g == 0) {
                return;
            }
            let h = a.l.width > 0 || a.l.height > 0;
            let i = a.m.width > 0;
            if (!h) {
                let j = a.d;
                let k = a.f;
                let l = GeometryUtil.k(j, k);
                let m = { $type: Point_$type, x: (j.x - k.x) / l, y: (j.y - k.y) / l };
                let n = { $type: Point_$type, x: -m.y, y: m.x };
                let o = a.j;
                let p = a.h;
                let q = GeometryUtil.k(o, p);
                let r = { $type: Point_$type, x: (p.x - o.x) / q, y: (p.y - o.y) / q };
                let s = { $type: Point_$type, x: -r.y, y: r.x };
                k = { $type: Point_$type, x: k.x + n.x * g, y: k.y + n.y * g };
                j = { $type: Point_$type, x: j.x + n.x * g, y: j.y + n.y * g };
                o = { $type: Point_$type, x: o.x + s.x * g, y: o.y + s.y * g };
                p = { $type: Point_$type, x: p.x + s.x * g, y: p.y + s.y * g };
                if (a.m.width > 0 && a.m.height > 0) {
                    let t = { $type: Point_$type, x: j.x + m.x * g, y: j.y + m.y * g };
                    let u = { $type: Point_$type, x: k.x + m.x * -g, y: k.y + m.y * -g };
                    let v = { $type: Point_$type, x: p.x + r.x * g, y: p.y + r.y * g };
                    let w = { $type: Point_$type, x: o.x + r.x * -g, y: o.y + r.y * -g };
                    a.d = t;
                    a.f = u;
                    a.h = v;
                    a.j = w;
                    if (Math.abs((c - b) - Math.PI) <= 0.0001) {
                        let x = this.zh.ca;
                        let y = this.zh.b9;
                        let z = this.getEffectiveViewport1(this.zh);
                        let aa = ViewportUtils.e(d.x, x, y, z);
                        let ab = ViewportUtils.i(d.y, x, y, z);
                        let ac = { $type: Point_$type, x: aa, y: ab };
                        let ad = ViewportUtils.d(e, x, y, z);
                        let ae = ViewportUtils.h(e, x, y, z);
                        let af = Math.min(ad, ae);
                        let ag = j;
                        let ah = GeometryUtil.r(ag, k, ac, af - g);
                        if (!isNaN_(ah.c.x) && !isNaN_(ah.c.y) && !isNaN_(ah.d.x) && !isNaN_(ah.d.y)) {
                            if ((Math.pow(ag.x - ah.c.x, 2) + Math.pow(ag.y - ah.c.y, 2)) < (Math.pow(ag.x - ah.d.x, 2) + Math.pow(ag.y - ah.d.y, 2))) {
                                ag = ah.c;
                            }
                            else {
                                ag = ah.d;
                            }
                            a.d = ag;
                        }
                        let ai = o;
                        ah = GeometryUtil.r(ai, p, ac, af - g);
                        if (!isNaN_(ah.c.x) && !isNaN_(ah.c.y) && !isNaN_(ah.d.x) && !isNaN_(ah.d.y)) {
                            if ((Math.pow(ai.x - ah.c.x, 2) + Math.pow(ai.y - ah.c.y, 2)) < (Math.pow(ai.x - ah.d.x, 2) + Math.pow(ai.y - ah.d.y, 2))) {
                                ai = ah.c;
                            }
                            else {
                                ai = ah.d;
                            }
                            a.j = ai;
                        }
                        a.m = new Size(1, a.m.width - g, a.m.height - g);
                        let aj = ViewportUtils.d(f, x, y, z);
                        let ak = ViewportUtils.h(f, x, y, z);
                        let al = Math.min(aj, ak);
                        ah = GeometryUtil.r(j, k, ac, al + g);
                        if (!isNaN_(ah.c.x) && !isNaN_(ah.c.y) && !isNaN_(ah.d.x) && !isNaN_(ah.d.y)) {
                            let am;
                            if ((Math.pow(k.x - ah.c.x, 2) + Math.pow(k.y - ah.c.y, 2)) < (Math.pow(k.x - ah.d.x, 2) + Math.pow(k.y - ah.d.y, 2))) {
                                am = ah.c;
                            }
                            else {
                                am = ah.d;
                            }
                            a.f = am;
                        }
                        ah = GeometryUtil.r(p, o, ac, al + g);
                        if (!isNaN_(ah.c.x) && !isNaN_(ah.c.y) && !isNaN_(ah.d.x) && !isNaN_(ah.d.y)) {
                            let an;
                            if ((Math.pow(p.x - ah.c.x, 2) + Math.pow(p.y - ah.c.y, 2)) < (Math.pow(p.x - ah.d.x, 2) + Math.pow(p.y - ah.d.y, 2))) {
                                an = ah.c;
                            }
                            else {
                                an = ah.d;
                            }
                            a.h = an;
                        }
                        a.n = new Size(1, a.n.width + g, a.n.height + g);
                    }
                    else {
                        if (g < 0) {
                            let ao = GeometryUtil.w(a.d, a.f, a.j, a.h);
                            if (!isNaN_(ao.x)) {
                                a.d = ao;
                                a.j = ao;
                            }
                        }
                        a.m = new Size(1, a.m.width - g, a.m.height - g);
                        a.n = new Size(1, a.n.width + g, a.n.height + g);
                    }
                }
                else {
                    a.f = { $type: Point_$type, x: k.x + m.x * -g, y: k.y + m.y * -g };
                    a.h = { $type: Point_$type, x: p.x + r.x * g, y: p.y + r.y * g };
                    let ap = c - b;
                    if (Math.abs((c - b) - Math.PI) <= 0.0001) {
                        let aq = this.zh.ca;
                        let ar = this.zh.b9;
                        let as = this.getEffectiveViewport1(this.zh);
                        let at = ViewportUtils.e(d.x, aq, ar, as);
                        let au = ViewportUtils.i(d.y, aq, ar, as);
                        let av = { $type: Point_$type, x: at, y: au };
                        let aw = ViewportUtils.d(f, aq, ar, as);
                        let ax = ViewportUtils.h(f, aq, ar, as);
                        let ay = Math.min(aw, ax);
                        if (g > 0) {
                            k = { $type: Point_$type, x: k.x + m.x * -g, y: k.y + m.y * -g };
                            p = { $type: Point_$type, x: p.x + r.x * g, y: p.y + r.y * g };
                        }
                        let az = GeometryUtil.r(j, k, av, ay + g);
                        if (!isNaN_(az.c.x) && !isNaN_(az.c.y) && !isNaN_(az.d.x) && !isNaN_(az.d.y)) {
                            let a0;
                            if ((Math.pow(k.x - az.c.x, 2) + Math.pow(k.y - az.c.y, 2)) < (Math.pow(k.x - az.d.x, 2) + Math.pow(k.y - az.d.y, 2))) {
                                a0 = az.c;
                            }
                            else {
                                a0 = az.d;
                            }
                            a.f = a0;
                        }
                        az = GeometryUtil.r(p, o, av, ay + g);
                        if (!isNaN_(az.c.x) && !isNaN_(az.c.y) && !isNaN_(az.d.x) && !isNaN_(az.d.y)) {
                            let a1;
                            if ((Math.pow(p.x - az.c.x, 2) + Math.pow(p.y - az.c.y, 2)) < (Math.pow(p.x - az.d.x, 2) + Math.pow(p.y - az.d.y, 2))) {
                                a1 = az.c;
                            }
                            else {
                                a1 = az.d;
                            }
                            a.h = a1;
                        }
                        a.d = j;
                        a.j = o;
                        a.n = new Size(1, a.n.width + g, a.n.height + g);
                    }
                    else if (ap < Math.PI) {
                        let a2 = GeometryUtil.w(k, j, o, p);
                        if (!isNaN_(a2.x)) {
                            a.d = a2;
                            a.j = a2;
                        }
                        else {
                            a.d = j;
                            a.j = o;
                        }
                        a.n = new Size(1, a.n.width + g, a.n.height + g);
                    }
                    else {
                        j = { $type: Point_$type, x: j.x + m.x * 1000, y: j.y + m.y * 1000 };
                        o = { $type: Point_$type, x: o.x + r.x * -1000, y: o.y + r.y * -1000 };
                        let a3 = GeometryUtil.w(k, j, o, p);
                        if (!isNaN_(a3.x)) {
                            a.d = a3;
                            a.j = a3;
                        }
                        else {
                            a.d = j;
                            a.j = o;
                        }
                        a.n = new Size(1, a.n.width + g, a.n.height + g);
                    }
                }
            }
            else {
                let a4 = a.e;
                let a5 = a.f;
                let a6 = GeometryUtil.k(a4, a5);
                let a7 = { $type: Point_$type, x: (a4.x - a5.x) / a6, y: (a4.y - a5.y) / a6 };
                let a8 = { $type: Point_$type, x: -a7.y, y: a7.x };
                let a9 = a.j;
                let ba = a.i;
                let bb = GeometryUtil.k(a9, ba);
                let bc = { $type: Point_$type, x: (ba.x - a9.x) / bb, y: (ba.y - a9.y) / bb };
                let bd = { $type: Point_$type, x: -bc.y, y: bc.x };
                a5 = { $type: Point_$type, x: a5.x + a8.x * g, y: a5.y + a8.y * g };
                a4 = { $type: Point_$type, x: a4.x + a8.x * g, y: a4.y + a8.y * g };
                a9 = { $type: Point_$type, x: a9.x + bd.x * g, y: a9.y + bd.y * g };
                ba = { $type: Point_$type, x: ba.x + bd.x * g, y: ba.y + bd.y * g };
                let be = { $type: Point_$type, x: a.d.x + a8.x * g, y: a.d.y + a8.y * g };
                let bf = { $type: Point_$type, x: a.k.x + bd.x * g, y: a.k.y + bd.y * g };
                let bg = { $type: Point_$type, x: a.g.x + a8.x * g, y: a.g.y + a8.y * g };
                let bh = { $type: Point_$type, x: a.h.x + bd.x * g, y: a.h.y + bd.y * g };
                if (!i) {
                    a5 = { $type: Point_$type, x: a5.x + a7.x * -g, y: a5.y + a7.y * -g };
                    bg = { $type: Point_$type, x: bg.x + a7.x * -g, y: bg.y + a7.y * -g };
                    ba = { $type: Point_$type, x: ba.x + bc.x * g, y: ba.y + bc.y * g };
                    bh = { $type: Point_$type, x: bh.x + bc.x * g, y: bh.y + bc.y * g };
                    if (Math.abs((c - b) - Math.PI) <= 0.0001) {
                        let bi = this.zh.ca;
                        let bj = this.zh.b9;
                        let bk = this.getEffectiveViewport1(this.zh);
                        let bl = ViewportUtils.e(d.x, bi, bj, bk);
                        let bm = ViewportUtils.i(d.y, bi, bj, bk);
                        let bn = { $type: Point_$type, x: bl, y: bm };
                        let bo = ViewportUtils.d(f, bi, bj, bk);
                        let bp = ViewportUtils.h(f, bi, bj, bk);
                        let bq = Math.min(bo, bp);
                        let br = this.aek(bg, a.g, bn, bq + g);
                        bg = !isNaN_(br.x) ? br : bg;
                        br = this.aek(bh, a.h, bn, bq + g);
                        bh = !isNaN_(br.x) ? br : bh;
                    }
                    else {
                        a4 = { $type: Point_$type, x: a4.x + a7.x * 1000, y: a4.y + a7.y * 1000 };
                        a9 = { $type: Point_$type, x: a9.x + bc.x * -1000, y: a9.y + bc.y * -1000 };
                        let bs = GeometryUtil.w(a5, a4, bf, ba);
                        be = !isNaN_(bs.x) ? bs : be;
                        a9 = !isNaN_(bs.x) ? bs : a9;
                    }
                    a.d = be;
                    a.e = be;
                    a.j = be;
                    a.k = be;
                    a.f = a5;
                    a.g = bg;
                    a.h = bh;
                    a.i = ba;
                    a.n = new Size(1, a.n.width + g, a.n.height + g);
                }
                else {
                    a5 = { $type: Point_$type, x: a5.x + a7.x * -g, y: a5.y + a7.y * -g };
                    bg = { $type: Point_$type, x: bg.x + a7.x * -g, y: bg.y + a7.y * -g };
                    ba = { $type: Point_$type, x: ba.x + bc.x * g, y: ba.y + bc.y * g };
                    bh = { $type: Point_$type, x: bh.x + bc.x * g, y: bh.y + bc.y * g };
                    be = { $type: Point_$type, x: be.x + a7.x * g, y: be.y + a7.y * g };
                    a4 = { $type: Point_$type, x: a4.x + a7.x * g, y: a4.y + a7.y * g };
                    a9 = { $type: Point_$type, x: a9.x + bc.x * -g, y: a9.y + bc.y * -g };
                    bf = { $type: Point_$type, x: bf.x + bc.x * -g, y: bf.y + bc.y * -g };
                    if (Math.abs((c - b) - Math.PI) <= 0.0001) {
                        let bt = this.zh.ca;
                        let bu = this.zh.b9;
                        let bv = this.getEffectiveViewport1(this.zh);
                        let bw = ViewportUtils.e(d.x, bt, bu, bv);
                        let bx = ViewportUtils.i(d.y, bt, bu, bv);
                        let by = { $type: Point_$type, x: bw, y: bx };
                        let bz = ViewportUtils.d(e, bt, bu, bv);
                        let b0 = ViewportUtils.h(e, bt, bu, bv);
                        let b1 = Math.min(bz, b0);
                        let b2 = this.aek(be, a.d, by, b1 - g);
                        be = !isNaN_(b2.x) ? b2 : be;
                        b2 = this.aek(bf, a.k, by, b1 - g);
                        bf = !isNaN_(b2.x) ? b2 : bf;
                        let b3 = ViewportUtils.d(f, bt, bu, bv);
                        let b4 = ViewportUtils.h(f, bt, bu, bv);
                        let b5 = Math.min(b3, b4);
                        b2 = this.aek(bg, a.g, by, b5 + g);
                        bg = !isNaN_(b2.x) ? b2 : bg;
                        b2 = this.aek(bh, a.h, by, b5 + g);
                        bh = !isNaN_(b2.x) ? b2 : bh;
                    }
                    else {
                        if (g < 0) {
                            let b6 = GeometryUtil.w(a4, a5, a9, ba);
                            if (!isNaN_(b6.x)) {
                                be = b6;
                                a4 = b6;
                                a9 = b6;
                                bf = b6;
                            }
                        }
                    }
                    a.d = be;
                    a.e = a4;
                    a.j = a9;
                    a.k = bf;
                    a.f = a5;
                    a.g = bg;
                    a.h = bh;
                    a.i = ba;
                    a.m = new Size(1, a.m.width - g, a.m.height - g);
                    a.n = new Size(1, a.n.width + g, a.n.height + g);
                }
            }
        }
        aek(a, b, c, d) {
            let e = GeometryUtil.r(a, b, c, d);
            if (!isNaN_(e.c.x) && !isNaN_(e.c.y) && !isNaN_(e.d.x) && !isNaN_(e.d.y)) {
                let f;
                if ((Math.pow(a.x - e.c.x, 2) + Math.pow(a.y - e.c.y, 2)) < (Math.pow(a.x - e.d.x, 2) + Math.pow(a.y - e.d.y, 2))) {
                    return e.c;
                }
                else {
                    return e.d;
                }
            }
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        aej(a, b, c, d, e, f, g, h) {
            let i = SliceCoords.b(a, b, c, d, e, f, g, h);
            let j = this.zo.m;
            let k = Math.abs((e - d) - (Math.PI * 2)) <= 0.0001;
            if (this.ad4 && !k) {
                this.aef(i, d, e, h, f, g, 0.5);
            }
            let l = new PathFigure();
            l._startPoint = i.d;
            l._isClosed = true;
            l._segments.add(((() => {
                let $ret = new LineSegment(1);
                $ret.c = i.f;
                return $ret;
            })()));
            l._segments.add(((() => {
                let $ret = new ArcSegment();
                $ret.e = i.h;
                $ret.f = i.n;
                $ret.d = 1;
                $ret.b = i.c;
                return $ret;
            })()));
            l._segments.add(((() => {
                let $ret = new LineSegment(1);
                $ret.c = i.j;
                return $ret;
            })()));
            if (!this.ad4 || (i.m.width > 0 && i.m.height > 0)) {
                l._segments.add(((() => {
                    let $ret = new ArcSegment();
                    $ret.e = i.d;
                    $ret.f = i.m;
                    $ret.d = 0;
                    $ret.b = i.c;
                    return $ret;
                })()));
            }
            let m = new PathGeometry();
            m.c.add(l);
            return m;
        }
        ad2(a, b, c, d, e, f, g, h) {
            let i = SliceCoords.b(a, b, c, d, e, f, g, h);
            if (isNaN_(i.n.width) || isNaN_(d) || isNaN_(e)) {
                return null;
            }
            let j = ViewportUtils.e(0.5, a, b, c);
            let k = ViewportUtils.i(0.5, a, b, c);
            return new PieSliceCollisionGeometry(j, k, i.n.width, i.m.width, d, e);
        }
        aei(a, b, c, d, e, f, g, h, i, j) {
            let k = SliceCoords.a(a, b, c, d, e, f, g, h, i, j);
            if (k == null) {
                return this.aej(a, b, c, d, e, f, g, h);
            }
            let l = this.zo.m;
            let m = Math.abs((e - d) - (Math.PI * 2)) <= 0.0001;
            if (this.ad4 && !m) {
                this.aef(k, d, e, h, f, g, 0.5);
            }
            let n = new PathFigure();
            n._startPoint = k.d;
            n._isClosed = true;
            let o = ((d + ((e - d) * 0.5)) * 180 / Math.PI) + 90;
            let p = new Size(1, k.l.width * (f / g), k.l.height * (f / g));
            if (!this.ad4 || (k.m.width > 0 && k.m.height > 0)) {
                n._segments.add(((() => {
                    let $ret = new ArcSegment();
                    $ret.e = k.e;
                    $ret.f = p;
                    $ret.c = o;
                    $ret.d = 1;
                    $ret.b = false;
                    return $ret;
                })()));
            }
            n._segments.add(((() => {
                let $ret = new LineSegment(1);
                $ret.c = k.f;
                return $ret;
            })()));
            n._segments.add(((() => {
                let $ret = new ArcSegment();
                $ret.e = k.g;
                $ret.f = k.l;
                $ret.c = o;
                $ret.d = 1;
                $ret.b = false;
                return $ret;
            })()));
            n._segments.add(((() => {
                let $ret = new ArcSegment();
                $ret.e = k.h;
                $ret.f = k.n;
                $ret.d = 1;
                $ret.b = k.c;
                return $ret;
            })()));
            n._segments.add(((() => {
                let $ret = new ArcSegment();
                $ret.e = k.i;
                $ret.f = k.l;
                $ret.c = o;
                $ret.d = 1;
                $ret.b = false;
                return $ret;
            })()));
            n._segments.add(((() => {
                let $ret = new LineSegment(1);
                $ret.c = k.j;
                return $ret;
            })()));
            if (!this.ad4 || (k.m.width > 0 && k.m.height > 0)) {
                n._segments.add(((() => {
                    let $ret = new ArcSegment();
                    $ret.e = k.k;
                    $ret.f = p;
                    $ret.c = o;
                    $ret.d = 1;
                    $ret.b = false;
                    return $ret;
                })()));
                n._segments.add(((() => {
                    let $ret = new ArcSegment();
                    $ret.e = k.d;
                    $ret.f = k.m;
                    $ret.d = 0;
                    $ret.b = k.c;
                    return $ret;
                })()));
            }
            let q = new PathGeometry();
            q.c.add(n);
            return q;
        }
        rg(a, b, c, d) {
            super.rg(a, b, c, d);
            switch (b) {
                case RadialPieSeries.$$p[0]:
                case RadialPieSeries.$$p[1]:
                case "UseInsetOutlines":
                    this.q9();
                    break;
                case "FastItemsSource":
                    if (c != null) {
                        if (this.ad1 != null) {
                            c.deregisterColumn(this.ad1);
                        }
                    }
                    if (d != null) {
                        if (this.aea != null) {
                            this.ad1 = this.dn(this.aea);
                        }
                    }
                    break;
                case "LegendLabelMemberPath":
                    if (this.dp != null) {
                        this.dp.deregisterColumn(this.ad1);
                        this.ad1 = this.dn(this.aea);
                        this.pk();
                        this.pz();
                    }
                    break;
            }
        }
        wx(a) {
            let b = this.adz.ca;
            let c = this.adz.b9;
            let d = this.getEffectiveViewport1(this.adz);
            let e = this.wt(this.adz);
            let f = this.zf.or(c, b, d, e);
            let g = { $type: Point_$type, x: 0.5, y: 0.5 };
            let h = GeometryUtil.j(g, a);
            let i = this.zi.h;
            let j = 0;
            for (let k = 0; k < i.count; k++) {
                let l = i._inner[k][0];
                let m = Math.min(i._inner[k][2], f.maxLength);
                let n = i._inner[k][3];
                if (isNaN_(n)) {
                    continue;
                }
                l = l % 6.28318531;
                if (l < 0) {
                    l += 6.28318531;
                }
                if (h >= l - (n * 0.5) && h <= l + (n * 0.5)) {
                    let o = Math.max(0, 0.5 * this.zf.sa);
                    let p = o;
                    p = Math.max(p, f.minLength);
                    let q = SliceCoords.b(b, c, d, l - (n * 0.5), l + (n * 0.5), p, m, g);
                    let r = GeometryUtil.u({ $type: Point_$type, x: ViewportUtils.e(g.x, b, c, d), y: ViewportUtils.i(g.y, b, c, d) }, MathUtil.f(l), q.n.width);
                    let s = 1.7976931348623157E+308;
                    let t = 1.7976931348623157E+308;
                    let u = -1.7976931348623157E+308;
                    let v = -1.7976931348623157E+308;
                    s = Math.min(s, q.d.x);
                    s = Math.min(s, q.f.x);
                    s = Math.min(s, q.h.x);
                    s = Math.min(s, q.j.x);
                    s = Math.min(s, r.x);
                    t = Math.min(t, q.d.y);
                    t = Math.min(t, q.f.y);
                    t = Math.min(t, q.h.y);
                    t = Math.min(t, q.j.y);
                    t = Math.min(t, r.y);
                    u = Math.max(u, q.d.x);
                    u = Math.max(u, q.f.x);
                    u = Math.max(u, q.h.x);
                    u = Math.max(u, q.j.x);
                    u = Math.max(u, r.x);
                    v = Math.max(v, q.d.y);
                    v = Math.max(v, q.f.y);
                    v = Math.max(v, q.h.y);
                    v = Math.max(v, q.j.y);
                    v = Math.max(v, r.y);
                    return new Rect(0, s, t, u - s, v - t);
                }
                j++;
            }
            return new Rect(0, 0, 0, 0, 0);
        }
        ky(a) {
            if (this.y9 != null && this.y9.dj && a == this.y9.othersIndex) {
                return null;
            }
            if (this.ad1 != null) {
                return this.ad1.item(a);
            }
            return null;
        }
        ed(a, b, c, d, e) {
            if (super.ed(a, b, c, d, e)) {
                let f = typeCast(ProportionalCategoryAngleAxis.$, this.y9) !== null && this.y9.hasOthersCategory;
                if (e && (this.ady == 1 || (this.ady == 2 && !f))) {
                    let g = this.y9;
                    let h = new ScalerParams(1, this.dc.xm, this.w2, g.df);
                    h.c = this.getEffectiveViewport1(this.cw);
                    let i = this.zf;
                    let j = new ScalerParams(1, this.dc.xm, this.w2, i.df);
                    j.c = this.getEffectiveViewport1(this.cw);
                    let k = this.aad;
                    for (let l = 0; l < this.dp.count; l++) {
                        let m = this.dp.item(l);
                        let n = NaN;
                        if (m != null) {
                            n = this.jf(m);
                        }
                        if (n == 0) {
                            let o = new SeriesPointOfInterest();
                            o.f = this.abd(n, m, l, d, k, c, b, false);
                            o.b = ((() => {
                                let $ret = new DataContext();
                                $ret.item = m;
                                $ret.series = this;
                                return $ret;
                            })());
                            o.g = this.vq;
                            o.c = l;
                            if (this.ha) {
                                o.g = this.vx(l);
                            }
                            let p = false;
                            for (let q = 0; q < a.count; q++) {
                                if (o.c < a._inner[q].c) {
                                    a.insert(q, o);
                                    p = true;
                                    break;
                                }
                            }
                            if (!p) {
                                a.add(o);
                            }
                        }
                    }
                }
                return true;
            }
            return false;
        }
        ak(a, b) {
            let c = new List$1(ChartSelection.$, 0);
            this.qa(a, c, b);
            return c.toArray();
        }
        qa(a, b, c) {
            if (this.za == 0) {
                super.qa(a, b, c);
                return;
            }
            let d = this.cw.ca;
            let e = this.cw.b9;
            let f = this.getEffectiveViewport1(this.cw);
            let g = this.dc.xu(this.w2, this.getEffectiveViewport(), d);
            let h = this.zf.or(e, d, f, g);
            let i = { $type: Point_$type, x: 0.5, y: 0.5 };
            let j = this.zf;
            let k = Math.max(0, 0.5 * j.sa);
            let l = k;
            l = Math.max(l, h.minLength);
            let m = this.y9.ou(d, e, f);
            let n = this.y9 != null && this.y9.dj;
            let o = new CollisionRect(0, this.dc.xr(a));
            for (let p = 0; p < this.y9.o6; p++) {
                let q = typeCast(RadialBaseView.$, this.cw);
                let r = q.da.getBucket(p);
                let s = this.acr(this.y9, d, e, f);
                if (n) {
                    m = this.z8(p, d, e, f);
                    s = this.acq(p, this.y9, d, e, f);
                    if (isNaN_(s)) {
                        s = 0;
                    }
                }
                r[0] = this.y9.getScaledAngle(r[0]) + s;
                let t = r[0];
                let u = Math.min(this.zg.b.sh(r[2]), h.maxLength);
                let v = this.ad2(d, e, f, t - (m * 0.5), t + (m * 0.5), l, u, i);
                if (v.collidesWithHeavy(o)) {
                    if (c == 7 || c == 6) {
                        b.add(((() => {
                            let $ret = new ChartSelection();
                            $ret.series = this;
                            return $ret;
                        })()));
                        return;
                    }
                    if (c == 2 || c == 1) {
                        b.add(((() => {
                            let $ret = new ChartSelection();
                            $ret.item = this.dp.item(p);
                            return $ret;
                        })()));
                    }
                    else {
                        b.add(((() => {
                            let $ret = new ChartSelection();
                            $ret.item = this.dp.item(p);
                            $ret.series = this;
                            return $ret;
                        })()));
                    }
                }
            }
        }
    }
    RadialPieSeries.$t = markType(RadialPieSeries, 'RadialPieSeries', AnchoredRadialSeries.$);
    RadialPieSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RadialPieSeries, 'raisePropertyChanged', ['RadiusX:ad5:aeg', [1, 2], 'RadiusY:ad6:aeh', [1, 2]]);
    return RadialPieSeries;
})();
/**
 * @hidden
 */
export let RadialPieSeriesView = /*@__PURE__*/ (() => {
    class RadialPieSeriesView extends AnchoredRadialSeriesView {
        constructor(a) {
            super(a);
            this.di = null;
            this.dj = null;
            this.dk = null;
            this.dq = new Path();
            this.di = a;
            this.dj = ((() => {
                let $ret = new Pool$1(Path.$);
                $ret.create = runOn(this, this.dr);
                $ret.activate = runOn(this, this.dl);
                $ret.disactivate = runOn(this, this.dn);
                $ret.destroy = runOn(this, this.dm);
                return $ret;
            })());
        }
        a4() {
            super.a4();
            this.dk = new List$1(Path.$, 0);
            if (!this.t) {
                this.c9.xk = Defaults.c;
                this.c9.jt = Defaults.i;
            }
        }
        dr() {
            let a = ((() => {
                let $ret = new Path();
                $ret.dataContext = ((() => {
                    let $ret = new DataContext();
                    $ret.series = this.f;
                    return $ret;
                })());
                return $ret;
            })());
            this.dk.add(a);
            a._visibility = 1;
            return a;
        }
        dl(a) {
            a._visibility = 0;
        }
        dn(a) {
            a._visibility = 1;
        }
        dm(a) {
            this.dk.remove(a);
        }
        bs(a, b) {
            super.bs(a, b);
            let c = a;
        }
        ak(a) {
            return this.dk._inner[a];
        }
        aj(a) {
            let b = this.dk._inner[a];
            this.dq._visibility = b._visibility;
            this.dq.an = b.an;
            let c = this.b4(a);
            this.dq._fill = c;
            this.dq._stroke = c;
            this.dq.ad = this.f.ig;
            return this.dq;
        }
        bj(a, b) {
            super.bj(a, b);
            if (a.d) {
                for (let c = 0; c < this.dk.count; c++) {
                    let d = this.ai(c, b);
                    if (this.di.ad4) {
                        a.aa();
                        a.ac(d);
                    }
                    a.t(d);
                    if (this.di.ad4) {
                        a.z();
                    }
                }
            }
        }
        dp() {
            this.a2();
        }
        ax(a) {
            super.ax(a);
            let b = 0;
            for (let c of fromEnum(this.dj.a)) {
                this.f.bc.exportPathData(a, c, "slice" + b, ["Main", "Fill"]);
                b++;
            }
        }
    }
    RadialPieSeriesView.$t = markType(RadialPieSeriesView, 'RadialPieSeriesView', AnchoredRadialSeriesView.$);
    return RadialPieSeriesView;
})();
