/*
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 { RingSeriesBase } from "./RingSeriesBase";
import { RingCollection } from "./RingCollection";
import { DependencyProperty } from "igniteui-angular-core";
import { fromEnum, Number_$type, fromEn, markType, markDep } from "igniteui-angular-core";
import { Ring } from "./Ring";
import { ArcItem } from "./ArcItem";
import { List$1 } from "igniteui-angular-core";
import { IgQueue$1 } from "./IgQueue$1";
import { BrushCollection } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
/**
 * @hidden
 */
export let HierarchicalRingSeries = /*@__PURE__*/ (() => {
    class HierarchicalRingSeries extends RingSeriesBase {
        constructor() {
            super();
            this.ep = null;
            this.ab = HierarchicalRingSeries.$;
        }
        au() {
            if (this.itemsSource == null) {
                return new RingCollection();
            }
            this.ep = this.eq(this.itemsSource);
            return this.ep;
        }
        c4(a, b, c, d) {
            super.c4(a, b, c, d);
            switch (b) {
                case RingSeriesBase.$$p[33]:
                    let e = c;
                    let f = d;
                    let g = f - e;
                    if (this.ep != null && this.ep.count > 0) {
                        for (let h = 0; h < this.ep.count; h++) {
                            let i = this.ep._inner[h];
                            for (let j of fromEnum(i.g)) {
                                j.k = j.k + g;
                            }
                        }
                    }
                    break;
                case RingSeriesBase.$$p[0]:
                    this.c2();
                    break;
                case HierarchicalRingSeries.$$p[0]:
                    this.c3();
                    break;
            }
            if (this.ep != null && this.aw.e()) {
                let k = false;
                for (let l of fromEnum(this.ep)) {
                    l.o();
                    if (l.f()) {
                        k = true;
                    }
                }
                if (k) {
                    for (let m of fromEnum(this.ep)) {
                        m.c.aw.l();
                    }
                }
            }
        }
        c3() {
            if (this.ax != null) {
                this.ax.bx();
                this.ax.b2();
            }
        }
        c2() {
            if (this.ep != null) {
                for (let a of fromEnum(this.ep)) {
                    for (let b of fromEnum(a.g)) {
                        this.ev(b);
                    }
                }
            }
        }
        c8() {
            if (this.ep != null && this.ep.count > 0) {
                let a = this.ep._inner[this.ep.count - 1];
                this.width = a.q.width;
                this.height = a.q.height;
                this.aw.m(a.p.x, a.p.y);
            }
        }
        c7() {
            for (let a = 0; a < this.ep.count; a++) {
                for (let b of fromEnum(this.ep._inner[a].ringControl.arcs.a)) {
                    b.gv();
                }
            }
        }
        es(obj_) {
            let memberPath_ = this.et;
            if ((obj_[memberPath_] !== undefined)) {
                return (obj_[memberPath_]);
            }
            return null;
        }
        eq(a) {
            let b = new IgQueue$1(ArcItem.$);
            let c = new IgQueue$1(ArcItem.$);
            let d = ((() => {
                let $ret = new ArcItem();
                $ret.m = 0;
                $ret.h = a;
                $ret.n = this.cs;
                $ret.c = this.ap;
                $ret.j = this.a8;
                return $ret;
            })());
            d.p(this.ba);
            let e = ((() => {
                let $ret = new ArcItem();
                $ret.m = -1;
                $ret.h = null;
                return $ret;
            })());
            c.h(d);
            b.h(e);
            let f = new RingCollection();
            let g = null;
            let h = -1;
            while (c.f > 0) {
                let i;
                let j = c.g(i);
                i = j.p0;
                let k;
                let l = b.g(k);
                k = l.p0;
                if (i == null) {
                    continue;
                }
                let m = 0;
                for (let n of fromEnum(i.g)) {
                    let o = this.es(n.g);
                    if ((o != null && this.er(o) == false) || n.c) {
                        let p = ((() => {
                            let $ret = new ArcItem();
                            $ret.m = i.m + 1;
                            $ret.h = n.c ? ((() => {
                                let $ret = new List$1(Number_$type, 0);
                                $ret.add(0);
                                return $ret;
                            })()) : o;
                            $ret.l = m;
                            $ret.b = i;
                            $ret.n = this.cs;
                            $ret.e = n;
                            return $ret;
                        })());
                        p.p(this.ba);
                        c.h(p);
                        b.h(i);
                    }
                    m++;
                }
                let q = this.eo(i, k, h, g);
                if (q != g) {
                    f.add(q);
                    g = q;
                }
                h = i.m;
            }
            return f;
        }
        eo(a, b, c, d) {
            a.k = a.e == null ? this.ba : a.e.e;
            a.i = a.e == null ? 360 : a.e.d;
            this.ev(a);
            if (a.m != c) {
                let e = ((() => {
                    let $ret = new Ring();
                    $ret.c = this;
                    return $ret;
                })());
                e.g.add(a);
                a.d = e;
                return e;
            }
            a.d = d;
            d.g.add(a);
            return d;
        }
        er(a) {
            for (let b of fromEn(a)) {
                return false;
            }
            return true;
        }
        ev(a) {
            if (a.b == null) {
                a.a = this.ak;
            }
            else if (a.b.m == 0) {
                a.a = new BrushCollection();
                if (a.b.a != null) {
                    a.a.add(a.b.a.item(a.l % a.b.a.count));
                }
            }
            else {
                a.a = a.b.a;
            }
        }
    }
    HierarchicalRingSeries.$t = markType(HierarchicalRingSeries, 'HierarchicalRingSeries', RingSeriesBase.$);
    HierarchicalRingSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HierarchicalRingSeries, 'c6', ['ChildrenMemberPath:et:ew', [2]]);
    return HierarchicalRingSeries;
})();
