/*
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 { PieChartBase } from "./PieChartBase";
import { DependencyProperty } from "igniteui-angular-core";
import { PieChartBaseView } from "./PieChartBaseView";
import { Base, Number_$type, typeCast, fromEnum, markType, markDep, IEnumerable_$type, INotifyPropertyChanged_$type, PropertyChangedEventArgs, Point_$type, delegateCombine, enumGetBox, EnumUtil, Delegate_$type, Boolean_$type, delegateRemove, runOn, fromEn, toEnum } from "igniteui-angular-core";
import { Control } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { NotifyCollectionChangedEventArgs } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { FastItemsSource } from "igniteui-angular-core";
import { IChartLegend_$type } from "igniteui-angular-core";
import { ContentControl } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { PieSliceDataContext } from "./PieSliceDataContext";
import { UIElement } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { Visibility_$type } from "igniteui-angular-core";
import { OthersCategoryType_$type } from "./OthersCategoryType";
import { BrushCollection } from "igniteui-angular-core";
import { isNaN_, isInfinity, intDivide } from "igniteui-angular-core";
import { ILegendSeries_$type } from "igniteui-angular-core";
import { ILegendTemplateProvider_$type } from "igniteui-angular-core";
import { LabelsPosition_$type } from "./LabelsPosition";
import { Style } from "igniteui-angular-core";
import { LeaderLineType_$type } from "./LeaderLineType";
import { DataTemplate } from "igniteui-angular-core";
import { ILegendOwner_$type } from "igniteui-angular-core";
import { PropertyUpdatedEventArgs } from "igniteui-angular-core";
import { Size } from "igniteui-angular-core";
import { ObservableCollection$1 } from "igniteui-angular-core";
import { DomRenderer_$type } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { HoleDimensionsChangedEventArgs } from "./HoleDimensionsChangedEventArgs";
import { DoughnutChartVisualData } from "./DoughnutChartVisualData";
import { RingSeriesVisualDataList } from "./RingSeriesVisualDataList";
import { RectData } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { PieLegendTemplates } from "./PieLegendTemplates";
import { BrushUtil } from "igniteui-angular-core";
import { FontUtil } from "igniteui-angular-core";
import { DOMEventProxy } from "igniteui-angular-core";
import { SliceVisualData } from "./SliceVisualData";
import { RingSeriesVisualData } from "./RingSeriesVisualData";
import { RingVisualDataList } from "./RingVisualDataList";
import { RingVisualData } from "./RingVisualData";
import { ArcVisualDataList } from "./ArcVisualDataList";
import { ArcVisualData } from "./ArcVisualData";
import { SliceVisualDataList } from "./SliceVisualDataList";
import { PointData } from "igniteui-angular-core";
import { AppearanceHelper } from "igniteui-angular-core";
import { PathVisualData } from "igniteui-angular-core";
import { DoughnutChartLabelVisualData } from "./DoughnutChartLabelVisualData";
import { RectUtil } from "igniteui-angular-core";
import { SizeData } from "igniteui-angular-core";
/**
 * @hidden
 */
export class Arc extends PieChartBase {
    constructor() {
        super();
        this.hd = null;
        this.hb = null;
        this.hg = 0;
        this.ab = Arc.$;
    }
    ar() {
        return new ArcView(this);
    }
    e6(a) {
        super.e6(a);
        this.hc = a;
    }
    get he() {
        return this.hd;
    }
    set he(a) {
        let b = this.hd;
        this.hd = a;
        this.hc.b6(b, this.hd);
    }
    get hh() {
        if (this.he != null) {
            return this.he.i;
        }
        return 0;
    }
    e5(a, b) {
        super.e5(a, b);
        if (this.he != null) {
            this.he.c.at.bu(a, b);
        }
    }
    ek(a, b) {
        if (this.he != null && this.he.d != null) {
            super.ek(a, b);
            let c = this.hf(a);
            if (c != null) {
                this.he.d.bj(c, b);
            }
        }
    }
    fk(a, b) {
        if (this.he != null && this.he.d != null) {
            super.fk(a, b);
            let c = this.hf(a);
            if (c != null) {
                this.he.d.b5(c, b);
            }
        }
    }
    hf(a) {
        for (let b of fromEnum(this.hb.g)) {
            if (b.b == a) {
                return b;
            }
        }
        return null;
    }
    fj(a) {
        if (this.bq) {
            this.e9();
            this.fh();
            this.fg();
        }
    }
    e9() {
        if (this.itemsSource == null || this.a5 == null) {
            this.bg.count = 0;
            return;
        }
        let a = this.b2.count;
        let b = this.b1.count > 0;
        let c = PieChartBase.cs(this.cf);
        let d = PieChartBase.cs(this.cf);
        this.cx = a;
        if (b) {
            a++;
        }
        for (let e = 0; e < a; e++) {
            let f = false;
            let g;
            if (e == a - 1 && b) {
                g = this.cp;
                f = true;
            }
            else {
                g = this.be.item(this.b2._inner[e]);
            }
            if (this.gz == 1) {
                d += PieChartBase.cs(Math.abs(g) * this.hi / this.cu);
            }
            else {
                d -= PieChartBase.cs(Math.abs(g) * this.hi / this.cu);
            }
            let h = this.bg.item(e);
            if (this.cc >= 100) {
                h._visibility = 1;
            }
            else {
                h._visibility = 0;
            }
            h.aw = true;
            h.a3 = c;
            h.ax = d;
            h.a1 = h.a0 = this.cc;
            h.isOthersSlice = f;
            h.ay = this.cb;
            h.a5 = e;
            h.dataContext = f ? this.b0 : this.a5.item(this.b2._inner[e]);
            h.isExploded = this.explodedSlices.contains(e);
            h.isSelected = this.selectedSlices.contains(e);
            c = d;
            h.aw = false;
        }
        this.bg.count = a;
        if (this.hb != null) {
            this.hb.q(this);
        }
    }
    fg() {
        let a = typeCast(IChartLegend_$type, this.legend);
        if (a == null) {
            return;
        }
        if (this.ba == null || this.ba.count == 0 || ((this.he != null && this.he.c != null) && (this.he.d != null && !this.he.d.series.contains(this.he.c)))) {
            a.clearLegendItemsForSeries(this.he.c);
            return;
        }
        this.bz = new List$1(UIElement.$, 0);
        for (let b of fromEnum(this.bg.a)) {
            let c = new ContentControl();
            let d = this.cy(b);
            let e = b.b0;
            let f = b.isOthersSlice ? this.dz : (this.bb != null && this.bb.count > 0) ? this.bb.item(this.b2._inner[b.a5]) : null;
            f = (f == null && this.ba.count > 0) ? this.ba.item(this.b2._inner[b.a5]) : f;
            c.content = ((() => {
                let $ret = new PieSliceDataContext();
                $ret.series = this.he.c;
                $ret.slice = b;
                $ret.item = b.dataContext;
                $ret.itemBrush = e;
                $ret.legendLabel = f != null ? f.toString() : null;
                $ret.itemLabel = d != null ? d.toString() : null;
                $ret.percentValue = this.ck(b);
                $ret.isOthersSlice = b.isOthersSlice;
                return $ret;
            })());
            let g = c.content;
            if (this.au != null) {
                let h = this.au(g);
                if (h != null) {
                    g.legendLabel = h.toString();
                }
            }
            if (this.legendItemTemplate != null) {
                c.ah = this.legendItemTemplate;
            }
            this.bz.add(c);
        }
        if (a.isItemwise) {
            let i = a;
            i.createLegendItemsInsert(this.bz, this.he.c);
        }
    }
    fa(a, b, c, d) {
        super.fa(a, b, c, d);
        switch (b) {
            case Arc.$$p[0]:
                this.hg = d;
                this.e9();
                this.e8();
                this.fh();
                this.ff();
                break;
            case "RadiusFactor":
                if (this.he != null && this.he.d != null) {
                    this.he.d.bw();
                }
                break;
            case "Legend":
                let e = typeCast(IChartLegend_$type, c);
                if (e != null && this.he != null && this.he.c != null) {
                    e.clearLegendItemsForSeries(this.he.c);
                }
                break;
        }
    }
    hj() {
        return this.as.ac();
    }
}
Arc.$t = markType(Arc, 'Arc', PieChartBase.$);
Arc.$$p = markDep(DependencyProperty, PropertyMetadata, Arc, 'fc', ['EndAngle:hi:hl', [1, 360]]);
/**
 * @hidden
 */
export class ArcItem extends Base {
    constructor() {
        super();
        this.d = null;
        this.b = null;
        this.n = null;
        this.l = 0;
        this.m = 0;
        this.k = 0;
        this.i = 0;
        this.j = 0;
        this.c = 0;
        this.a = null;
        this.g = null;
        this.e = null;
        this.h = null;
        this.k = 0;
        this.i = 360;
        this.g = new List$1(SliceItem.$, 0);
    }
    o(a, b) {
        let c = 0;
        let d = 0;
        let e = new List$1(Number_$type, 0);
        let f = new List$1(Number_$type, 0);
        let g = new List$1(Base.$, 0);
        this.g.clear();
        if (this.h == null) {
            return;
        }
        let h = new FastItemsSource();
        h.e = this.h;
        let i = this.f(h, this.n);
        if (i == null || i.count == 0) {
            h.deregisterColumn(i);
            h.m();
            return;
        }
        for (let j of fromEnum(i)) {
            if (isNaN_(j) || isInfinity(j) || j <= 0) {
                continue;
            }
            c = c + j;
        }
        for (let k = 0; k < i.count; k++) {
            let l = i.item(k);
            if (isNaN_(l) || isInfinity(l) || l <= 0) {
                continue;
            }
            let m = this.c == 1 ? l / c : l;
            let n = this.c == 1 ? this.j / 100 : this.j;
            if (m <= n) {
                d = d + l;
                f.add(k);
                g.add1(h.item(k));
            }
            else {
                e.add(k);
            }
        }
        let o = e.count;
        let p = f.count > 0;
        let q = PieChartBase.cs(a);
        let r = PieChartBase.cs(a);
        if (p) {
            o++;
        }
        for (let s = 0; s < o; s++) {
            let t = false;
            let u;
            if (s == o - 1 && p) {
                u = d;
                t = true;
            }
            else {
                u = i.item(e._inner[s]);
            }
            let v = 1;
            if (v == 1) {
                r += PieChartBase.cs(Math.abs(u) * b / c);
            }
            else {
                r -= PieChartBase.cs(Math.abs(u) * b / c);
            }
            this.g.add(((() => {
                let $ret = new SliceItem();
                $ret.e = q;
                $ret.d = r - q;
                $ret.g = t ? g : h.item(e._inner[s]);
                return $ret;
            })()));
            q = r;
        }
        h.deregisterColumn(i);
        h.m();
    }
    f(a, b) {
        let c = null;
        return a.registerColumn(b, c, false);
    }
    p(a) {
        let b = this.e == null ? a : this.e.e;
        let c = this.e == null ? 360 : this.e.d;
        this.o(b, c);
    }
    q(a) {
        this.g.clear();
        for (let b = 0; b < a.bg.count; b++) {
            let c = a.bg.item(b);
            this.g.add(((() => {
                let $ret = new SliceItem();
                $ret.e = c.a3;
                $ret.d = c.ax - c.a3;
                $ret.f = b;
                $ret.a = this;
                $ret.g = c.dataContext;
                $ret.c = c.isOthersSlice;
                $ret.b = c;
                return $ret;
            })()));
        }
    }
}
ArcItem.$t = markType(ArcItem, 'ArcItem');
/**
 * @hidden
 */
export class RingSeriesBase extends Control {
    constructor() {
        super();
        this.ao = null;
        this.at = null;
        this.propertyChanged = null;
        this.propertyUpdated = null;
        this.a7 = null;
        this.aw = false;
        this.av = false;
        this.a5 = null;
        this.dq = null;
        this.as = null;
        this.cq = null;
        this.dq = { $type: Point_$type, x: 0, y: 0 };
        this.ao = (a, b) => this.cl(a, b.propertyName, b.oldValue, b.newValue);
        this.propertyUpdated = delegateCombine(this.propertyUpdated, this.ao);
        this.as = this.ar();
        this.ci(this.as);
        this.as.k();
        this.a5 = (a, b) => this.cc(b.action, b.position, b.count, b.propertyName);
    }
    cn(a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        if (this.propertyUpdated != null) {
            this.propertyUpdated(this, new PropertyUpdatedEventArgs(a, b, c));
        }
    }
    get du() {
        if (this.dt != null) {
            return this.dt;
        }
        if (this.at != null && this.at.cg != null) {
            return this.at.cg;
        }
        return null;
    }
    set du(a) {
        let b = this.du;
        if (this.dt != null && a != this.dt) {
            a = this.dt;
        }
        this.cn("SelectedStyleResolved", b, a);
    }
    get b5() {
        return this.a7;
    }
    set b5(a) {
        let b = this.a7;
        this.a7 = a;
        this.cn("TextStyle", b, a);
    }
    get cr() {
        return typeCast(DataTemplate.$, this.c(RingSeriesBase.c3));
    }
    set cr(a) {
        this.h(RingSeriesBase.c3, a);
    }
    get ax() {
        return this.c(RingSeriesBase.cw);
    }
    set ax(a) {
        this.aw = true;
        this.h(RingSeriesBase.cw, a);
    }
    get ay() {
        if (!this.aw) {
            return this.at.ax;
        }
        else {
            return this.ax;
        }
    }
    cl(a, b, c, d) {
        if (b == RingSeriesBase.$$p[4]) {
            this.au = ((() => {
                let $ret = new FastItemsSource();
                $ret.e = d;
                return $ret;
            })());
        }
        if (b == RingSeriesBase.$$p[1]) {
            if (typeCast(FastItemsSource.$, c) != null) {
                let e = (typeCast(FastItemsSource.$, c));
                e.event = delegateRemove(e.event, this.a5);
                this.av = false;
            }
            if (typeCast(FastItemsSource.$, d) != null) {
                let f = (typeCast(FastItemsSource.$, d));
                f.event = delegateCombine(f.event, this.a5);
                this.av = true;
            }
            this.ck();
        }
        switch (b) {
            case RingSeriesBase.$$p[24]:
                this.du = d;
                break;
            case RingSeriesBase.$$p[28]:
                this.ck();
                break;
        }
    }
    get container() {
        return this.at;
    }
    get isStacked() {
        return false;
    }
    get isVertical() {
        return false;
    }
    get isUsableInLegend() {
        return true;
    }
    get hasMarkers() {
        return false;
    }
    get hasSubItems() {
        return false;
    }
    cc(a, b, c, d) {
        this.ck();
    }
    ar() {
        return new RingSeriesBaseView(this);
    }
    ci(a) {
    }
    cm(a) {
        this.as.n(a);
    }
    cb() {
        if (this.as != null) {
            this.as.i();
        }
    }
    cf(a, b) {
        this.cd(new NotifyCollectionChangedEventArgs(1, 0, b, a));
    }
    ch(a, b, c) {
        this.cd(new NotifyCollectionChangedEventArgs(2, 2, c, b, a));
    }
    ce() {
        this.cd(new NotifyCollectionChangedEventArgs(0, 4));
    }
    cg(a, b) {
        this.cd(new NotifyCollectionChangedEventArgs(1, 1, b, a));
    }
    cd(a) {
        if (this.au != null) {
            this.au.handleCollectionChanged(a);
        }
    }
    resolveLegendIndex() {
        return -1;
    }
    forSubItems(a) {
    }
}
RingSeriesBase.$t = markType(RingSeriesBase, 'RingSeriesBase', Control.$, [INotifyPropertyChanged_$type, ILegendSeries_$type, ILegendTemplateProvider_$type]);
RingSeriesBase.c3 = DependencyProperty.i("LabelTemplate", DataTemplate.$, RingSeriesBase.$, new PropertyMetadata(2, null, (a, b) => (typeCast(RingSeriesBase.$, a)).cn("LabelTemplate", b.oldValue, b.newValue)));
RingSeriesBase.cw = DependencyProperty.i("IsSurfaceInteractionDisabled", Boolean_$type, RingSeriesBase.$, new PropertyMetadata(2, false, (a, b) => a.cn("IsSurfaceInteractionDisabled", b.oldValue, b.newValue)));
RingSeriesBase.$$p = markDep(DependencyProperty, PropertyMetadata, RingSeriesBase, 'cn', ['Brushes:ag:cs', [BrushCollection.$, null], 'FastItemsSource:au:ct', [FastItemsSource.$], 'FormatLabel:am:cu', [Delegate_$type], 'FormatLegendLabel:an:cv', [Delegate_$type], 'ItemsSource::cx', [IEnumerable_$type, null], 'LabelExtent:a0:cy', [1, 10], 'LabelInnerColor:dn:cz', [Brush.$, null], 'LabelMemberPath:bg:c0', [2], 'LabelOuterColor:dp:c1', [Brush.$, null], 'LabelsPosition:aj:c2', [LabelsPosition_$type, enumGetBox(LabelsPosition_$type, 1)], 'LeaderLineMargin:a1:c4', [1, 6], 'LeaderLineStyle:dr:c5', [Style.$, null], 'LeaderLineType:ak:c6', [LeaderLineType_$type, enumGetBox(LeaderLineType_$type, 0)], 'LeaderLineVisibility:dw:c7', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'LegendItemBadgeTemplate::c8', [DataTemplate.$, null], 'LegendItemTemplate::c9', [DataTemplate.$, null], 'LegendLabelMemberPath:br:da', [2], 'Legend::db', [IChartLegend_$type, null], 'OthersCategoryStyle:ds:dc', [Style.$, null], 'OthersCategoryText:bv:dd', [2, "Others"], 'OthersCategoryThreshold:a2:de', [1, 3], 'OthersCategoryType:al:df', [OthersCategoryType_$type, enumGetBox(OthersCategoryType_$type, 1)], 'Outlines:ah:dg', [BrushCollection.$, null], 'RadiusFactor:a3:dh', [1, 0.9], 'SelectedStyle:dt:di', [Style.$, null], 'StartAngle:a4:dj', [1, 0], 'ToolTip::dk', [4, null], 'ToolTipStyle:dv:dl', [Style.$, null], 'ValueMemberPath:b9:dm', [2, null]]);
/**
 * @hidden
 */
export class Ring extends Base {
    constructor() {
        super();
        this.j = 0;
        this.h = 0;
        this.q = new Size();
        this.p = null;
        this._ringControl = null;
        this.b = null;
        this.i = 0;
        this.g = null;
        this.d = null;
        this.e = false;
        this.p = { $type: Point_$type, x: 0, y: 0 };
        this.q = new Size(1, 0, 0);
        this.ringControl = ((() => {
            let $ret = new RingControl();
            $ret.ai = this;
            return $ret;
        })());
        this.g = new List$1(ArcItem.$, 0);
        this.e = true;
    }
    get ringControl() {
        return this._ringControl;
    }
    set ringControl(a) {
        this._ringControl = a;
    }
    get c() {
        return this.b;
    }
    set c(a) {
        this.b = a;
        this.b.as.h(this.ringControl);
        if (this.ringControl != null) {
            this.ringControl.ak.s(a);
        }
    }
    f() {
        if (this.ringControl != null && this.ringControl.ak.d()) {
            let a, b;
            a = this.p.x - this.c.dq.x;
            b = this.p.y - this.c.dq.y;
            this.ringControl.ak.v(a, b);
            return this.ringControl.an();
        }
        return false;
    }
    o() {
        if (this.ringControl != null) {
            this.ringControl.width = this.q.width;
            this.ringControl.height = this.q.height;
            this.c.as.h(this.ringControl);
            this.ringControl.ao = this.g;
        }
    }
    l(source_, a, b) {
        this.ringControl.as(source_, a, b);
    }
    k(source_) {
        this.ringControl.ar(source_);
    }
    m(source_, a, b) {
        this.ringControl.at(source_, a, b);
    }
    n(source_, a, b, c) {
        this.ringControl.au(source_, a, b, c);
    }
}
Ring.$t = markType(Ring, 'Ring');
/**
 * @hidden
 */
export class RingCollection extends ObservableCollection$1 {
    constructor() {
        super(Ring.$, 0);
    }
    p() {
        for (let a of fromEnum(this)) {
            if (a.e) {
                let b = 0;
                let c = a.ringControl.arcs.count;
                while (b < c) {
                    a.ringControl.arcs.destroy(a.ringControl.arcs.item(b));
                    b++;
                }
                a.ringControl.arcs.count = 0;
                a.ringControl = null;
            }
        }
        super.p();
    }
    u(a) {
        let b = this._inner[a];
        if (b.e) {
            b.ringControl.arcs.destroy(b.ringControl.arcs.item(a));
            b.ringControl.arcs.count = 0;
            b.ringControl = null;
        }
        super.u(a);
    }
}
RingCollection.$t = markType(RingCollection, 'RingCollection', ObservableCollection$1.$.specialize(Ring.$));
/**
 * @hidden
 */
export class RingControl extends Control {
    constructor() {
        super();
        this.ak = null;
        this.ah = null;
        this.arcs = null;
        this.ao = null;
        this.a0 = null;
        this.propertyChanged = null;
        this.propertyUpdated = null;
        this.ab = RingControl.$;
        this.ak = this.aj();
        this.ax(this.ak);
        this.ak.r();
        this.arcs = ((() => {
            let $ret = new Pool$1(Arc.$);
            $ret.create = runOn(this.ak, this.ak.a);
            $ret.activate = runOn(this.ak, this.ak.l);
            $ret.disactivate = runOn(this.ak, this.ak.n);
            $ret.destroy = runOn(this.ak, this.ak.m);
            return $ret;
        })());
    }
    get al() {
        return this.ai.c;
    }
    get ai() {
        return this.ah;
    }
    set ai(a) {
        this.ah = a;
        if (this.ah == null) {
            this.ak.s(null);
        }
        else {
            this.ak.s(this.ah.c);
        }
    }
    aj() {
        return new RingControlView(this);
    }
    ax(a) {
    }
    az(a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        if (this.propertyUpdated != null) {
            this.propertyUpdated(this, new PropertyUpdatedEventArgs(a, b, c));
        }
    }
    aw() {
        this.an();
    }
    an() {
        if (this.ao == null) {
            return false;
        }
        if (!this.ak.d()) {
            return false;
        }
        let a = 0;
        let b = false;
        for (let c of fromEnum(this.ao)) {
            let d = this.arcs.item(a);
            d.hb = c;
            if (d.cl != this.ai.h) {
                d.cl = this.ai.h;
            }
            if ((d.width != this.ai.q.width || d.height != this.ai.q.height) && d.as.r()) {
                d.width = this.ai.q.width;
                d.height = this.ai.q.height;
                this.ak.ab(d);
                b = true;
            }
            if (d.ct != c.k) {
                d.ct = c.k;
            }
            if (d.hi != c.i) {
                d.hi = c.i;
            }
            if (d.itemsSource != c.h) {
                d.itemsSource = c.h;
            }
            if (d.ag != c.a) {
                d.ag = c.a;
            }
            this.ak.t(d, 0, 0);
            a++;
        }
        this.arcs.count = a;
        return b;
    }
    ay(a) {
        this.ak.w(a);
    }
    av() {
        this.ak.q();
    }
    ap() {
        return this.ak.j();
    }
    as(source_, a, b) {
        for (let c = 0; c < this.arcs.count; c++) {
            this.arcs.item(c).es(source_, a, b);
        }
    }
    ar(source_) {
        for (let a = 0; a < this.arcs.count; a++) {
            this.arcs.item(a).eq(source_);
        }
    }
    at(source_, a, b) {
        for (let c = 0; c < this.arcs.count; c++) {
            this.arcs.item(c).et(source_, a, b);
        }
    }
    au(source_, a, b, c) {
        for (let d = 0; d < this.arcs.count; d++) {
            this.arcs.item(d).eu(source_, a, b, c);
        }
    }
}
RingControl.$t = markType(RingControl, 'RingControl', Control.$, [INotifyPropertyChanged_$type]);
/**
 * @hidden
 */
export class RingSeriesCollection extends ObservableCollection$1 {
    constructor() {
        super(RingSeriesBase.$, 0);
    }
}
RingSeriesCollection.$t = markType(RingSeriesCollection, 'RingSeriesCollection', ObservableCollection$1.$.specialize(RingSeriesBase.$));
/**
 * @hidden
 */
export class SliceItem extends Base {
    constructor() {
        super();
        this.e = 0;
        this.d = 0;
        this.a = null;
        this.f = 0;
        this.b = null;
        this.g = null;
        this.c = false;
    }
}
SliceItem.$t = markType(SliceItem, 'SliceItem');
/**
 * @hidden
 */
export class SliceCollection extends ObservableCollection$1 {
    constructor() {
        super(SliceItem.$, 0);
        this.ae = false;
        this.ag = false;
    }
    r(a, b) {
        if (this.contains(b)) {
            return;
        }
        let c = this.ah(b.b);
        if (c != -1) {
            super.x(c, b);
        }
        else {
            super.r(a, b);
            if (this.ae) {
                if (this.ag) {
                    b.b.isSelected = true;
                }
                else {
                    b.b.isExploded = true;
                }
            }
        }
    }
    x(a, b) {
        if (this.ae) {
            if (this.ag) {
                this._inner[a].b.isSelected = false;
            }
            else {
                this._inner[a].b.isExploded = false;
            }
        }
        super.x(a, b);
    }
    u(a) {
        let b = this._inner[a];
        super.u(a);
        if (this.ae) {
            if (this.ag) {
                b.b.isSelected = false;
            }
            else {
                b.b.isExploded = false;
            }
        }
    }
    remove(a) {
        let b = this.ah(a.b);
        if (b != -1) {
            this.u(b);
            return true;
        }
        else {
            return false;
        }
    }
    p() {
        while (this.count > 0) {
            this.u(0);
        }
    }
    ah(a) {
        for (let b = 0; b < this.count; b++) {
            if (this._inner[b].b == a) {
                return b;
            }
        }
        return -1;
    }
}
SliceCollection.$t = markType(SliceCollection, 'SliceCollection', ObservableCollection$1.$.specialize(SliceItem.$));
/**
 * @hidden
 */
export class XamDoughnutChart extends Control {
    constructor() {
        super();
        this.al = new RingSeriesCollection();
        this.aj = new RingCollection();
        this.ap = ((() => {
            let $ret = new SliceCollection();
            $ret.ae = true;
            $ret.ag = true;
            return $ret;
        })());
        this.ao = ((() => {
            let $ret = new SliceCollection();
            $ret.ae = true;
            $ret.ag = false;
            return $ret;
        })());
        this.ah = null;
        this.a0 = NaN;
        this.az = 1;
        this.au = null;
        this.sliceClick = null;
        this.propertyChanged = null;
        this.propertyUpdated = null;
        this.holeDimensionsChanged = null;
        let a = this.at();
        this.bv(a);
        a.s();
        this.ab = XamDoughnutChart.$;
        this.ah = (b, c) => this.bz(b, c.propertyName, c.oldValue, c.newValue);
        this.propertyUpdated = delegateCombine(this.propertyUpdated, this.ah);
        let b = this.series;
        b.collectionChanged = delegateCombine(b.collectionChanged, runOn(this, this.b6));
    }
    get ak() {
        return this.aj;
    }
    get series() {
        return this.al;
    }
    b6(a, b) {
        let c = new List$1(RingSeriesBase.$, 0);
        if (b.oldItems != null) {
            for (let d of fromEn(b.oldItems)) {
                if (b.newItems == null || !b.newItems.contains(d)) {
                    d.cb();
                    this.au.w(d);
                }
            }
        }
        this.bx();
        this.b2();
    }
    get a3() {
        return this.c(XamDoughnutChart.cc);
    }
    set a3(a) {
        this.h(XamDoughnutChart.cc, a);
    }
    get ar() {
        return this.ap;
    }
    set ar(a) {
        this.ap.clear();
        this.ap.ae = false;
        this.ap = a;
        this.ap.ae = true;
        this.ap.ag = true;
        for (let b = 0; b < this.ap.count; b++) {
            this.ap._inner[b].b.isSelected = true;
        }
    }
    get aq() {
        return this.ao;
    }
    set aq(a) {
        this.ao.clear();
        this.ao.ae = false;
        this.ao = a;
        this.ao.ae = true;
        this.ao.ag = false;
        for (let b = 0; b < this.ao.count; b++) {
            this.ao._inner[b].b.isExploded = true;
        }
    }
    get a4() {
        return this.a0;
    }
    set a4(a) {
        let b = this.a0;
        this.a0 = a;
        this.b1("PixelScalingRatio", b, this.a0);
    }
    get a1() {
        return this.az;
    }
    set a1(a) {
        let b = this.az;
        this.az = a;
        this.b1("ActualPixelScalingRatio", b, this.az);
    }
    destroy() {
        this.au.v(null);
        for (let a of fromEnum(this.series)) {
            a.cb();
        }
    }
    b5(a, b) {
        if (b) {
            this.ar.add(a);
        }
        else {
            this.ar.remove(a);
        }
    }
    bj(a, b) {
        if (b) {
            this.aq.add(a);
        }
        else {
            this.aq.remove(a);
        }
    }
    bz(a, b, c, d) {
        switch (b) {
            case XamDoughnutChart.$$p[5]:
                for (let e of fromEnum(this.series)) {
                    e.du = d;
                }
                break;
            case XamDoughnutChart.$$p[0]:
                for (let f = 0; f < this.aj.count; f++) {
                    for (let g of fromEnum(this.aj._inner[f].ringControl.arcs.a)) {
                        g.bp = this.av;
                    }
                }
                break;
            case XamDoughnutChart.$$p[1]:
                for (let h = 0; h < this.aj.count; h++) {
                    for (let i of fromEnum(this.aj._inner[h].ringControl.arcs.a)) {
                        i.bq = this.aw;
                    }
                }
                break;
            case "PixelScalingRatio":
                let j = DeviceUtils.a(this.a4);
                if (isNaN_(j)) {
                    this.a1 = 1;
                }
                else {
                    this.a1 = j;
                }
                break;
            case "ActualPixelScalingRatio":
                for (let k of fromEnum(this.aj)) {
                    for (let l of fromEnum(k.ringControl.arcs.a)) {
                        l.cd = this.a1;
                    }
                }
                break;
        }
    }
    at() {
        return new XamDoughnutChartView(this);
    }
    bv(a) {
        this.au = a;
    }
    b2() {
        this.by();
        this.b4();
        this.b3();
        this.bw();
        this.au.z();
    }
    b4() {
        for (let a of fromEnum(this.series)) {
            a.cp();
        }
    }
    bw() {
        let a = this.au.ab;
        if (a.isEmpty || a.width == 0 || a.height == 0) {
            return;
        }
        let b = { $type: Point_$type, x: a.width / 2, y: a.height / 2 };
        let c = Math.min(a.width / 2, a.height / 2);
        let d = 0.9;
        if (this.series.count > 0) {
            d = this.series._inner[0].a3;
            if (isNaN_(d) || isInfinity(d) || d < 0) {
                d = 0;
            }
            else if (d > 1) {
                d = 1;
            }
        }
        let e = this.a3 * c / 100 * d;
        this.au.x(e * 2, e * 2);
        this.au.u(b.x - e, b.y - e);
    }
    b3() {
        let a = false;
        for (let b of fromEnum(this.aj)) {
            if (b.f()) {
                a = true;
            }
        }
        if (a) {
            for (let c of fromEnum(this.aj)) {
                c.c.as.l();
            }
        }
    }
    by() {
        let a = this.au.ab;
        if (a.isEmpty || a.width == 0 || a.height == 0) {
            return;
        }
        let b = { $type: Point_$type, x: a.width / 2, y: a.height / 2 };
        let c = Math.min(a.width / 2, a.height / 2);
        let d = Math.max(a.width / 2, a.height / 2);
        if (a.width > a.height) {
            c = c + d;
            d = c - d;
            c = c - d;
        }
        let e = ((100 - this.a3) / 100 * c) / this.aj.count;
        let f = ((100 - this.a3) / 100 * d) / this.aj.count;
        let g = this.a3 * c / 100;
        let h = this.a3 * d / 100;
        let i = 1;
        for (let j of fromEnum(this.aj)) {
            let k = (g + (e * i));
            let l = (h + (f * i));
            j.i = e;
            j.q = new Size(1, k * 2, l * 2);
            j.p = { $type: Point_$type, x: b.x - k, y: b.y - l };
            j.h = 100 - (e / k * 100);
            j.o();
            i++;
        }
    }
    bx() {
        this.aq.clear();
        this.ar.clear();
        this.aj.clear();
        this.au.j();
        this.au.i();
        let a = 0;
        for (let b = 0; b < this.series.count; b++) {
            let c = this.series._inner[b];
            c.at = this;
            this.au.h(c);
            let series_ = c;
            series_.externalObject.sychronizeCollections();
            let d = c.aq();
            for (let e of fromEnum(d)) {
                e.d = this;
                e.j = a;
                this.aj.add(e);
                a++;
            }
        }
    }
    bt() {
        if (this.au != null) {
            this.height = this.au.ab.height;
            this.width = this.au.ab.width;
        }
        this.b2();
    }
    bu(a, b) {
        let c = a;
        let d = c.he.c;
        if (d.ay) {
            return;
        }
        if (this.sliceClick != null) {
            this.sliceClick(a, b);
        }
    }
    b1(a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        if (this.propertyUpdated != null) {
            this.propertyUpdated(this, new PropertyUpdatedEventArgs(a, b, c));
        }
    }
    onDetachedFromUI() {
        this.au.r();
        for (let a = 0; a < this.aj.count; a++) {
            for (let b of fromEnum(this.aj._inner[a].ringControl.arcs.a)) {
                b.onDetachedFromUI();
            }
            for (let c of fromEnum(this.aj._inner[a].ringControl.arcs.b)) {
                c.onDetachedFromUI();
            }
        }
    }
    onAttachedToUI() {
        this.au.q();
        for (let a = 0; a < this.aj.count; a++) {
            for (let b of fromEnum(this.aj._inner[a].ringControl.arcs.a)) {
                b.onAttachedToUI();
            }
            for (let c of fromEnum(this.aj._inner[a].ringControl.arcs.b)) {
                c.onAttachedToUI();
            }
        }
    }
    provideContainer(a) {
        this.au.v(a);
    }
    notifyResized() {
        this.au.y();
    }
    bd() {
        return this.au.g();
    }
    cf() {
        return this.au.aa;
    }
    a2() {
        return this.au.d;
    }
    bk() {
        let a;
        let b;
        for (let c = 0; c < this.series.count; c++) {
            b = this.series._inner[c].aq();
            for (let d = 0; d < b.count; d++) {
                a = b._inner[d].ringControl.ak.h();
                for (let e = 0; e < a.count; e++) {
                    a._inner[e].el();
                }
            }
        }
    }
    bs() {
        if (this.holeDimensionsChanged != null) {
            this.holeDimensionsChanged(this, new HoleDimensionsChangedEventArgs(this.cf(), this.a2()));
        }
    }
    as() {
        let a = new DoughnutChartVisualData();
        a.series = new RingSeriesVisualDataList();
        a.viewport = RectData.b(this.au.ab);
        this.au.o(a);
        return a;
    }
    bc() {
        let a = this.as();
        a.scaleByViewport();
        return a.serialize();
    }
    *_ay(a) {
        for (let b of fromEnum(this.series)) {
            if (PieChartBase.by(a, b.itemsSource)) {
                yield b;
            }
        }
    }
    ay(a) {
        return toEnum(() => this._ay(a));
    }
    bm(source_, a, b) {
        for (let c of fromEnum(this.ay(source_))) {
            c.cf(a, b);
        }
    }
    bp(source_, a, b, c) {
        for (let d of fromEnum(this.ay(source_))) {
            d.ch(a, b, c);
        }
    }
    bl(source_) {
        for (let a of fromEnum(this.ay(source_))) {
            a.ce();
        }
    }
    bn(source_, a, b) {
        for (let c of fromEnum(this.ay(source_))) {
            c.cg(a, b);
        }
    }
}
XamDoughnutChart.$t = markType(XamDoughnutChart, 'XamDoughnutChart', Control.$, [INotifyPropertyChanged_$type, ILegendOwner_$type]);
XamDoughnutChart.cc = DependencyProperty.i("InnerExtent", Number_$type, XamDoughnutChart.$, new PropertyMetadata(2, 40, (a, b) => {
    let c = b.newValue;
    if (c < 0 || c > 100) {
        if (b.oldValue != null) {
            a.a3 = b.oldValue;
        }
        return;
    }
    a.b2();
    a.b1("InnerExtent", b.oldValue, b.newValue);
}));
XamDoughnutChart.$$p = markDep(DependencyProperty, PropertyMetadata, XamDoughnutChart, 'b1', ['AllowSliceExplosion:av:b8', [0, true], 'AllowSliceSelection:aw:b9', [0, true], 'CenterData:a5:ca', [4, null], 'CenterDataTemplate:b7:cb', [DataTemplate.$, null], 'IsSurfaceInteractionDisabled:ax:cd', [0, false], 'SelectedStyle:cg:ce', [Style.$, null]]);
/**
 * @hidden
 */
export class ArcView extends PieChartBaseView {
    constructor(a) {
        super(a);
        this.b4 = null;
        this.b4 = a;
    }
    b6(a, b) {
        this.e.series = this.b4.he.c;
    }
    b5() {
        return this.f;
    }
    b7() {
        this.bb();
        this.bs = new Brush();
        let a = this.c.t();
        this.bs._fill = a.rootWrapper.getStyleProperty("color");
    }
}
ArcView.$t = markType(ArcView, 'ArcView', PieChartBaseView.$);
/**
 * @hidden
 */
export class RingControlView extends Base {
    constructor(a) {
        super();
        this.b = null;
        this.f = new List$1(Arc.$, 0);
        this.g = new List$1(Arc.$, 0);
        this.i = null;
        this.e = new Dictionary$2(Arc.$, DomRenderer_$type, 0);
        this.c = null;
        this.b = a;
    }
    a() {
        let a = new Arc();
        a.o = 0;
        a.n = 0;
        a.he = this.b.ai;
        this.f.add(a);
        this.z(a);
        if (a.eb != this.b.al.b5) {
            a.eb = this.b.al.b5;
        }
        a.cm = this.b.al.a0;
        a.at = this.b.al.am;
        a.di = this.b.al.bg;
        a.ao = this.b.al.aj;
        a.fu = this.b.al.cr;
        a.eg = this.b.al.b9;
        if (this.b.al.toolTip != null) {
            a.c0 = this.b.al.toolTip;
        }
        a.ha = this.b.al.dw;
        a.g6 = this.b.al.dr;
        a.ap = this.b.al.ak;
        a.cn = this.b.al.a1;
        a.co = this.b.al.a2;
        a.aq = this.b.al.al;
        a.dz = this.b.al.bv;
        a.g7 = this.b.al.ds;
        a.legend = this.b.al.legend;
        a.legendItemTemplate = this.b.al.legendItemTemplate;
        a.legendItemBadgeTemplate = this.b.al.legendItemBadgeTemplate;
        a.ah = this.b.al.ah;
        a.gx = this.b.al.dn;
        a.gy = this.b.al.dp;
        a.ct = this.b.al.a4;
        a.ag = this.b.al.ag;
        a.g8 = this.b.al.du;
        a.bv = true;
        a.cr = this.b.al.a3;
        a.bp = this.b.al.at.av;
        a.bq = this.b.al.at.aw;
        a.au = this.b.al.an;
        a.dv = this.b.al.br;
        a.cd = this.b.al.at.a1;
        return a;
    }
    l(a) {
        let b = this.e.item(a).rootWrapper;
        if (b != null) {
            b.show();
        }
        this.g.add(a);
    }
    n(a) {
        let b = this.e.item(a).rootWrapper;
        if (b != null) {
            b.hide();
        }
        this.g.remove(a);
    }
    m(a) {
        this.o(a);
        this.f.remove(a);
    }
    h() {
        return this.f;
    }
    r() {
    }
    aa() {
        this.b.aw();
    }
    t(a, b, c) {
        b = b + this.b.n;
        c = c + this.b.o;
        if (this.c != null) {
            b = b + this.c.n;
            c = c + this.c.o;
        }
        if (a.n != b || a.o != c) {
            a.n = b;
            a.o = c;
            this.u(a, this.e.item(a).rootWrapper);
        }
    }
    w(a) {
        if (a == null) {
            this.b.arcs.count = 0;
            for (let b of fromEnum(this.f)) {
                b.destroy();
            }
            this.f.clear();
            this.e.clear();
            this.g.clear();
            return;
        }
        this.i = a;
        this.i.rootWrapper.setStyleProperty("position", "relative");
        for (let c of fromEnum(this.f)) {
            let d = this.e.item(c);
            this.i.append(d.rootWrapper);
            c.hc.b7();
        }
        this.aa();
    }
    z(a) {
        let b = this.i.createElement("div");
        b.setStyleProperty("position", "absolute");
        this.e.addItem(a, this.i.getSubRenderer(b));
        this.k(a, b);
        this.u(a, b);
        if (this.i != null) {
            this.i.append(b);
        }
        a.provideContainer(this.e.item(a));
        b.setStyleProperty("position", "absolute");
    }
    k(a, b) {
        b.setStyleProperty("width", a.width.toString() + "px");
        b.setStyleProperty("height", a.height.toString() + "px");
    }
    u(a, b) {
        b.setStyleProperty("top", a.o.toString() + "px");
        b.setStyleProperty("left", a.n.toString() + "px");
    }
    o(a) {
        let b = this.e.item(a);
        b.rootWrapper.remove();
        this.e.removeItem(a);
        a.provideContainer(null);
    }
    ab(a) {
        this.k(a, a.hj().rootWrapper);
        a.ew(a.width, a.height);
    }
    d() {
        return this.i != null;
    }
    q() {
    }
    s(a) {
        this.c = a;
        if (a != null) {
            a.propertyUpdated = delegateCombine(a.propertyUpdated, runOn(this, this.y));
        }
    }
    y(a, b) {
        switch (b.propertyName) {
            case "LabelExtent":
                for (let c = 0; c < this.f.count; c++) {
                    this.f._inner[c].cm = b.newValue;
                }
                break;
            case "LabelMemberPath":
                for (let d = 0; d < this.f.count; d++) {
                    this.f._inner[d].di = b.newValue;
                }
                break;
            case "LabelsPosition":
                for (let e = 0; e < this.f.count; e++) {
                    this.f._inner[e].ao = EnumUtil.getEnumValue(LabelsPosition_$type, b.newValue);
                }
                break;
            case "LabelTemplate":
                for (let f = 0; f < this.f.count; f++) {
                    this.f._inner[f].fu = b.newValue;
                }
                break;
            case "ValueMemberPath":
                for (let g = 0; g < this.f.count; g++) {
                    this.f._inner[g].eg = b.newValue;
                }
                break;
            case "ToolTip":
                for (let h = 0; h < this.f.count; h++) {
                    this.f._inner[h].c0 = b.newValue;
                }
                break;
            case "LeaderLineVisibility":
                for (let i = 0; i < this.f.count; i++) {
                    this.f._inner[i].ha = EnumUtil.getEnumValue(Visibility_$type, b.newValue);
                }
                break;
            case "LeaderLineStyle":
                for (let j = 0; j < this.f.count; j++) {
                    this.f._inner[j].g6 = b.newValue;
                }
                break;
            case "LeaderLineType":
                for (let k = 0; k < this.f.count; k++) {
                    this.f._inner[k].ap = EnumUtil.getEnumValue(LeaderLineType_$type, b.newValue);
                }
                break;
            case "LeaderLineMargin":
                for (let l = 0; l < this.f.count; l++) {
                    this.f._inner[l].cn = b.newValue;
                }
                break;
            case "OthersCategoryThreshold":
                for (let m = 0; m < this.f.count; m++) {
                    this.f._inner[m].co = b.newValue;
                }
                break;
            case "OthersCategoryType":
                for (let n = 0; n < this.f.count; n++) {
                    this.f._inner[n].aq = EnumUtil.getEnumValue(OthersCategoryType_$type, b.newValue);
                }
                break;
            case "OthersCategoryText":
                for (let o = 0; o < this.f.count; o++) {
                    this.f._inner[o].dz = b.newValue;
                }
                break;
            case "OthersCategoryStyle":
                for (let p = 0; p < this.f.count; p++) {
                    this.f._inner[p].g7 = b.newValue;
                }
                break;
            case "Legend":
                for (let q = 0; q < this.f.count; q++) {
                    this.f._inner[q].legend = b.newValue;
                }
                break;
            case "LegendItemTemplate":
                for (let r = 0; r < this.f.count; r++) {
                    this.f._inner[r].legendItemTemplate = b.newValue;
                }
                break;
            case "LegendItemBadgeTemplate":
                for (let s = 0; s < this.f.count; s++) {
                    this.f._inner[s].legendItemBadgeTemplate = b.newValue;
                }
                break;
            case "Outlines":
                for (let t = 0; t < this.f.count; t++) {
                    this.f._inner[t].ah = b.newValue;
                }
                break;
            case "Brushes":
                for (let u = 0; u < this.f.count; u++) {
                    this.f._inner[u].ag = b.newValue;
                }
                break;
            case "SelectedStyle":
                for (let v = 0; v < this.f.count; v++) {
                    this.f._inner[v].g8 = b.newValue;
                }
                break;
            case "SelectedStyleResolved":
                for (let w = 0; w < this.f.count; w++) {
                    this.f._inner[w].g8 = b.newValue;
                }
                break;
            case "RadiusFactor":
                for (let x = 0; x < this.f.count; x++) {
                    this.f._inner[x].cr = b.newValue;
                }
                break;
        }
    }
    p() {
        for (let a of fromEnum(this.f)) {
            a.el();
        }
    }
    j() {
        return this.i;
    }
    v(a, b) {
        this.b.n = a;
        this.b.o = b;
        this.x();
    }
    x() {
        for (let a = 0; a < this.f.count; a++) {
            let b = this.f._inner[a];
            this.t(b, 0, 0);
        }
    }
}
RingControlView.$t = markType(RingControlView, 'RingControlView');
/**
 * @hidden
 */
export class RingSeriesBaseView extends Base {
    constructor(a) {
        super();
        this.c = null;
        this.f = null;
        this.g = null;
        this.a = null;
        this.b = null;
        this.o = null;
        this.d = null;
        this.f = new List$1(RingControl.$, 0);
        this.c = a;
    }
    k() {
        this.c.legendItemTemplate = ((() => {
            let $ret = new DataTemplate();
            $ret.render = PieLegendTemplates.c;
            $ret.measure = PieLegendTemplates.a;
            return $ret;
        })());
        this.c.legendItemBadgeTemplate = ((() => {
            let $ret = new DataTemplate();
            $ret.render = PieLegendTemplates.b;
            $ret.measure = PieLegendTemplates.d;
            return $ret;
        })());
    }
    h(a) {
        if (!this.f.contains(a)) {
            this.f.add(a);
        }
        if (this.g != null && (a.ap() != this.g)) {
            a.ay(this.g);
        }
    }
    j(a, b, c, d, e) {
        let f = BrushUtil.e("chart", a, b, c);
        b = f.p2;
        c = f.p3;
        let g = new Array(b.count * 2);
        for (let h = 0; h < g.length; h += 2) {
            g[h] = "#fff";
            g[h + 1] = b.item(intDivide(h, 2))._fill;
        }
        let i = BrushUtil.e("doughnut", a, b, c, g);
        b = i.p2;
        c = i.p3;
        d = new Brush();
        d._fill = this.g.rootWrapper.getStyleProperty("color");
        e = FontUtil.getFont(a);
        return {
            p1: b,
            p2: c,
            p3: d,
            p4: e
        };
    }
    n(a) {
        if (a == null) {
            for (let b of fromEnum(this.f)) {
                b.ay(null);
            }
            return;
        }
        this.g = a;
        let c;
        let d;
        let e;
        let f;
        let g = this.j(this.g, c, d, e, f);
        c = g.p1;
        d = g.p2;
        e = g.p3;
        f = g.p4;
        this.a = c;
        this.b = d;
        this.o = e;
        this.d = f;
        if (this.c.ag == null) {
            this.c.ag = this.a;
        }
        if (this.c.ah == null) {
            this.c.ah = this.b;
        }
        for (let h of fromEnum(this.f)) {
            h.ay(this.g);
        }
    }
    e() {
        return true;
    }
    i() {
        this.n(null);
    }
    l() {
        for (let a = 0; a < this.f.count; a++) {
            let b = this.f._inner[a];
            for (let c = 0; c < b.arcs.a.count; c++) {
                let d = b.arcs.a._inner[c];
                d.el();
            }
        }
    }
    m(a, b) {
        this.c.n = a;
        this.c.o = b;
        this.c.dq = { $type: Point_$type, x: a, y: b };
    }
}
RingSeriesBaseView.$t = markType(RingSeriesBaseView, 'RingSeriesBaseView');
/**
 * @hidden
 */
export class XamDoughnutChartView extends Base {
    constructor(a) {
        super();
        this.a = null;
        this.aa = null;
        this.d = 0;
        this.c = null;
        this.ab = null;
        this.f = null;
        this.e = null;
        this.b = null;
        this.ab = Rect.empty;
        this.aa = { $type: Point_$type, x: 0, y: 0 };
        this.d = 0;
        this.c = new List$1(RingSeriesBase.$, 0);
        this.a = a;
    }
    s() {
        this.p();
    }
    z() {
    }
    h(a) {
        if (!this.c.contains(a)) {
            a.cm(this.e);
            this.c.add(a);
        }
    }
    w(a) {
        if (this.c.contains(a)) {
            a.cm(null);
            this.c.remove(a);
        }
    }
    i() {
    }
    y() {
        if (this.e == null) {
            return;
        }
        this.p();
        let a = this.e.rootWrapper.width();
        let b = this.e.rootWrapper.height();
        this.ab = new Rect(0, 0, 0, a, b);
        if (this.b != null) {
            this.b.bf = this.ab;
        }
        this.a.bt();
    }
    v(a) {
        if (a == null) {
            if (this.b != null) {
                this.b.aq();
            }
            return;
        }
        let b = a;
        this.e = b;
        let c = this.e.rootWrapper.width();
        let d = this.e.rootWrapper.height();
        this.ab = new Rect(0, 0, 0, c, d);
        this.b = new DOMEventProxy(this.e.rootWrapper, this.e, false);
        this.b.bf = this.ab;
        let e = this.b;
        e.onMouseOver = delegateCombine(e.onMouseOver, runOn(this, this.m));
        let f = this.b;
        f.onMouseLeave = delegateCombine(f.onMouseLeave, runOn(this, this.l));
        let g = this.b;
        g.onMouseDown = delegateCombine(g.onMouseDown, runOn(this, this.k));
        let h = this.b;
        h.onMouseUp = delegateCombine(h.onMouseUp, runOn(this, this.n));
        this.y();
    }
    t(a, b, c) {
        for (let d = this.c.count - 1; d >= 0; d--) {
            let e = this.c._inner[d];
            if (e.ay) {
                continue;
            }
            let f = e.as.f;
            for (let g = 0; g < f.count; g++) {
                let h = f._inner[g];
                let i = h.arcs.a;
                for (let j = 0; j < i.count; j++) {
                    let k = i._inner[j];
                    let l = { $type: Point_$type, x: a.x - k.n, y: a.y - k.o };
                    b(k.as, l);
                    if (c == "mouseUp") {
                        let m = k.hc.b5();
                        if (m != null) {
                            return;
                        }
                    }
                }
            }
        }
    }
    n(a) {
        this.t(a, (b, c) => b.ak(c), "mouseUp");
    }
    k(a) {
        this.t(a, (b, c) => b.ah(c), "mouseDown");
    }
    l(a) {
        this.t(a, (b, c) => b.ai(c), "mouseLeave");
    }
    m(a, b, c) {
        this.t(a, (d, e) => d.aj(e, b, c), "mouseOver");
    }
    g() {
        return this.e.rootWrapper.getAttribute("id");
    }
    u(a, b) {
        if (!this.ab.isEmpty && this.ab.width != 0 && this.ab.height != 0) {
            let c = this.aa.x;
            let d = this.aa.y;
            this.aa.x = this.ab.width / 2;
            this.aa.y = this.ab.height / 2;
            if (this.aa.x != c || this.aa.y != d) {
                this.a.bs();
            }
        }
    }
    x(a, b) {
        let c = this.d;
        this.d = a / 2;
        if (c != this.d) {
            this.a.bs();
        }
    }
    j() {
    }
    o(a) {
        a.width = this.a.width;
        a.height = this.a.height;
        a.holeRadius = this.a.a2();
        for (let b = 0; b < this.a.series.count; b++) {
            a.series.add(new RingSeriesVisualData());
            a.series._inner[b].rings = new RingVisualDataList();
            a.series._inner[b].name = this.a.series._inner[b].name;
            a.series._inner[b].labelExtent = this.a.series._inner[b].a0;
            a.series._inner[b].leaderLineMargin = this.a.series._inner[b].a1;
            a.series._inner[b].leaderLineType = EnumUtil.getName(LeaderLineType_$type, this.a.series._inner[b].ak);
            a.series._inner[b].labelsPosition = EnumUtil.getName(LabelsPosition_$type, this.a.series._inner[b].aj);
            a.series._inner[b].leaderLineVisibility = this.a.series._inner[b].dw == 0;
            for (let c = 0; c < this.a.series._inner[b].aq().count; c++) {
                a.series._inner[b].rings.add(new RingVisualData());
                a.series._inner[b].rings._inner[c].arcs = new ArcVisualDataList();
                for (let d = 0; d < this.a.series._inner[b].aq()._inner[c].g.count; d++) {
                    a.series._inner[b].rings._inner[c].arcs.add(new ArcVisualData());
                    a.series._inner[b].rings._inner[c].arcs._inner[d].a = new SliceVisualDataList();
                    for (let e = 0; e < this.a.series._inner[b].aq()._inner[c].g._inner[d].g.count; e++) {
                        if (null == this.a.series._inner[b].aq()._inner[c].g._inner[d].g._inner[e].b) {
                            continue;
                        }
                        a.series._inner[b].rings._inner[c].arcs._inner[d].a.add(new SliceVisualData());
                        let f = new SliceVisualData();
                        let g = this.a.series._inner[b].aq()._inner[c].g._inner[d].g._inner[e].b;
                        f.visibility = g._visibility == 0;
                        f.endAngle = g.ax;
                        f.startAngle = g.a3;
                        f.radius = g.a2;
                        f.origin = PointData.b(g.b7);
                        f.explodedOrigin = PointData.b(g.b5);
                        f.index = g.a5;
                        f.isExploded = g.isExploded;
                        f.isSelected = g.isSelected;
                        f.outline = AppearanceHelper.a(g.b1);
                        f.backgroundPath = new PathVisualData(1, "slicePath", g.al.f());
                        a.series._inner[b].rings._inner[c].arcs._inner[d].a._inner[e] = f;
                        let h = g.aj;
                        if (null != h) {
                            a.series._inner[b].rings._inner[c].arcs._inner[d].a._inner[e].labelVisualData = ((() => {
                                let $ret = new DoughnutChartLabelVisualData();
                                $ret.labelSize = SizeData.b(RectUtil.z(h.ao));
                                $ret.labelValue = h.aj.ak;
                                return $ret;
                            })());
                            if (!isNaN_(h.n) && !isNaN_(h.o)) {
                                a.series._inner[b].rings._inner[c].arcs._inner[d].a._inner[e].labelVisualData.labelPosition = new PointData(h.n, h.o);
                            }
                        }
                    }
                }
            }
        }
    }
    p() {
        let a = this.a.a4;
        let b = this.a.a1;
        if (!isNaN_(a) && a != 0) {
            return;
        }
        if (window.devicePixelRatio != undefined && window.devicePixelRatio != b) {
            this.a.a1 = window.devicePixelRatio;
        }
    }
    r() {
        if (this.b != null) {
            this.b.bb(this.e.rootWrapper, "");
        }
    }
    q() {
        this.p();
        if (this.b != null) {
            this.b.ap(this.e.rootWrapper, "");
        }
    }
}
XamDoughnutChartView.$t = markType(XamDoughnutChartView, 'XamDoughnutChartView');
//# sourceMappingURL=Arc_combined.js.map