/*
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 { Defaults } from "./Defaults";
import { Point_$type, runOn, typeCast, markType, markDep, fromEnum } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { RadialBaseView } from "./RadialBaseView";
import { List$1 } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-angular-core";
import { PathFigure } from "igniteui-angular-core";
import { PolyLineSegment } from "igniteui-angular-core";
import { ViewportUtils } from "./ViewportUtils";
import { ChartSelection } from "./ChartSelection";
import { Clipper } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
import { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView";
/**
 * @hidden
 */
export let RadialColumnSeries = /*@__PURE__*/ (() => {
    class RadialColumnSeries extends AnchoredRadialSeries {
        constructor() {
            super();
            this.ab = RadialColumnSeries.$;
        }
        bk() {
            return new RadialColumnSeries();
        }
        get_e1() {
            return true;
        }
        get_fm() {
            return true;
        }
        jn() {
            if (!isNaN_(this.jm)) {
                return super.jn();
            }
            return Defaults.h;
        }
        ct() {
            return new RadialColumnSeriesView(this);
        }
        q7(a) {
            super.q7(a);
            this.adx = a;
        }
        ac() {
            super.ac();
            this.ry(false);
        }
        rg(a, b, c, d) {
            super.rg(a, b, c, d);
            switch (b) {
                case RadialColumnSeries.$$p[0]:
                case RadialColumnSeries.$$p[1]:
                    this.q9();
                    break;
            }
        }
        preferredCategoryMode(a) {
            return a != null && a == this.y9 ? 2 : 0;
        }
        pb(a, b) {
            super.pb(a, b);
            let c = b;
            if (a) {
                c.dj.count = 0;
            }
        }
        get_ef() {
            return true;
        }
        iy() {
            return this.y9.ou(this.cw.ca, this.cw.b9, this.getEffectiveViewport1(this.cw));
        }
        abk(a, b) {
            super.abk(a, b);
            let c = a.h;
            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 = b;
            let j = this.zf;
            let k = Math.max(0, 0.5 * j.sa);
            k = Math.max(k, h.minLength * 0.9);
            let l = ViewportUtils.d(k, d, e, f);
            let m = this.y9.ou(d, e, f);
            let n = Math.max(0.1 * this.zf.sb, k);
            let o = this.zg.d(0, n, d, e, f);
            let p = this.zg.e(0, n, d, e, f);
            let q = this.zg.d(m, n, d, e, f);
            let r = this.zg.e(m, n, d, e, f);
            let s = Math.sqrt((o - q) * (o - q) + (p - r) * (p - r));
            let t = { $type: Point_$type, x: ViewportUtils.e(0.5, d, e, f), y: ViewportUtils.i(0.5, d, e, f) };
            let u = this.acg.count;
            this.zo.a2(this, this.z5(), runOn(this, this.yx), this.aae(b), this.aaf(b));
            this.zo.r = this.ady;
            this.zo.s = this.adz;
            this.zo.k = this.ady;
            this.zo.l = this.adz;
            let v = false;
            let w = this.zo.b;
            if (w != null) {
                v = true;
            }
            let x = this.y9;
            let y = new ScalerParams(1, b.ca, b.b9, x.df);
            y.c = this.getEffectiveViewport();
            for (let z = 0; z < c.count; ++z) {
                let aa = Math.min(a.h._inner[z][2], h.maxLength * 1.1);
                let ab = this.zg.d(a.h._inner[z][0], aa, d, e, f);
                let ac = this.zg.e(a.h._inner[z][0], aa, d, e, f);
                let ad = Math.sqrt((ab - t.x) * (ab - t.x) + (ac - t.y) * (ac - t.y));
                let ae = ad;
                let af = l;
                if (v) {
                    this.add(c, z, u, x, y, b.t);
                }
                let ag = this.zo.k;
                let ah = this.zo.l;
                let ai = a.h._inner[z][0] - (Math.PI / 2);
                let aj = i.dj.item(z);
                let ak = 0 - (s / 2);
                let al = (s / 2);
                let am = Math.max(af, ae);
                let an = Math.min(af, ae);
                let ao = Math.cos(ai);
                let ap = Math.sin(ai);
                let aq = { $type: Point_$type, x: t.x + (ak * ao - am * ap), y: t.y + (ak * ap + am * ao) };
                let ar = { $type: Point_$type, x: t.x + (al * ao - am * ap), y: t.y + (al * ap + am * ao) };
                let as = { $type: Point_$type, x: t.x + (al * ao - an * ap), y: t.y + (al * ap + an * ao) };
                let at = { $type: Point_$type, x: t.x + (ak * ao - an * ap), y: t.y + (ak * ap + an * ao) };
                let au = new PathGeometry();
                let av = new PathFigure();
                av._startPoint = aq;
                av._isClosed = true;
                let aw = new PolyLineSegment();
                aw._points.add(ar);
                aw._points.add(as);
                aw._points.add(at);
                av._segments.add(aw);
                au.c.add(av);
                aj.an = au;
                this.zo.ad(aj, false, false, false, false);
            }
            i.dj.count = c.count;
            this.adx.dp();
        }
        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: ViewportUtils.e(0.5, d, e, f), y: ViewportUtils.i(0.5, d, e, f) };
            let j = this.dc.xr(a);
            let k = new Clipper(1, j.left, j.bottom, j.right, j.top, true);
            let l = this.zf;
            let m = Math.max(0, 0.5 * l.sa);
            m = Math.max(m, h.minLength * 0.9);
            let n = ViewportUtils.d(m, d, e, f);
            let o = this.y9.ou(d, e, f);
            let p = Math.max(0.1 * this.zf.sb, m);
            let q = this.zg.d(0, p, d, e, f);
            let r = this.zg.e(0, p, d, e, f);
            let s = this.zg.d(o, p, d, e, f);
            let t = this.zg.e(o, p, d, e, f);
            let u = Math.sqrt((q - s) * (q - s) + (r - t) * (r - t));
            let v = this.y9 != null && this.y9.dj;
            for (let w = 0; w < this.y9.o6; w++) {
                let x = typeCast(RadialBaseView.$, this.cw);
                let y = x.da.getBucket(w);
                let z = Math.min(this.zg.b.sh(y[2]), h.maxLength * 1.1);
                let aa = this.acr(this.y9, d, e, f);
                if (v) {
                    aa = this.acq(w, this.y9, d, e, f);
                    if (isNaN_(aa)) {
                        aa = 0;
                    }
                }
                y[0] = this.y9.getScaledAngle(y[0]) + aa;
                let ab = this.zg.d(y[0], z, d, e, f);
                let ac = this.zg.e(y[0], z, d, e, f);
                let ad = Math.sqrt((ab - i.x) * (ab - i.x) + (ac - i.y) * (ac - i.y));
                let ae = ad;
                let af = n;
                let ag = y[0] - (Math.PI / 2);
                let ah = 0 - (u / 2);
                let ai = (u / 2);
                let aj = Math.max(af, ae);
                let ak = Math.min(af, ae);
                let al = Math.cos(ag);
                let am = Math.sin(ag);
                let an = { $type: Point_$type, x: i.x + (ah * al - aj * am), y: i.y + (ah * am + aj * al) };
                let ao = { $type: Point_$type, x: i.x + (ai * al - aj * am), y: i.y + (ai * am + aj * al) };
                let ap = { $type: Point_$type, x: i.x + (ai * al - ak * am), y: i.y + (ai * am + ak * al) };
                let aq = { $type: Point_$type, x: i.x + (ah * al - ak * am), y: i.y + (ah * am + ak * al) };
                let ar = new List$1(Point_$type, 0);
                k.i = ar;
                k.j(an);
                k.j(ao);
                k.j(ap);
                k.j(aq);
                k.i = null;
                if (ar == null || ar.count == 0) {
                    continue;
                }
                if (c == 7 || c == 6) {
                    b.add(((() => {
                        let $ret = new ChartSelection();
                        $ret.series = this;
                        return $ret;
                    })()));
                    return;
                }
                else if (c == 2 || c == 1) {
                    b.add(((() => {
                        let $ret = new ChartSelection();
                        $ret.item = this.dp.item(w);
                        return $ret;
                    })()));
                }
                else {
                    b.add(((() => {
                        let $ret = new ChartSelection();
                        $ret.item = this.dp.item(w);
                        $ret.series = this;
                        return $ret;
                    })()));
                }
            }
        }
    }
    RadialColumnSeries.$t = markType(RadialColumnSeries, 'RadialColumnSeries', AnchoredRadialSeries.$);
    RadialColumnSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RadialColumnSeries, 'raisePropertyChanged', ['RadiusX:ady:ad2', [1, 0], 'RadiusY:adz:ad3', [1, 0]]);
    return RadialColumnSeries;
})();
/**
 * @hidden
 */
export let RadialColumnSeriesView = /*@__PURE__*/ (() => {
    class RadialColumnSeriesView extends AnchoredRadialSeriesView {
        constructor(a) {
            super(a);
            this.di = null;
            this.dj = null;
            this.dk = null;
            this.dr = new Path();
            this.di = a;
            this.dj = ((() => {
                let $ret = new Pool$1(Path.$);
                $ret.create = runOn(this, this.ds);
                $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;
            }
        }
        ds() {
            let a = new Path();
            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);
        }
        dq(a, b, c, d, e, f) {
            this.a2();
        }
        bs(a, b) {
            super.bs(a, b);
            let c = a;
        }
        bt(a, b) {
            super.bt(a, b);
            let c = a;
        }
        ak(a) {
            return this.dk._inner[a];
        }
        aj(a) {
            let b = this.dk._inner[a];
            this.dr._visibility = b._visibility;
            this.dr.an = b.an;
            let c = this.b4(a);
            this.dr._fill = c;
            this.dr._stroke = c;
            this.dr.ad = this.f.ig + 3;
            return this.dr;
        }
        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);
                    this.br(d, c, b);
                    a.t(d);
                }
            }
        }
        ax(a) {
            super.ax(a);
            let b = 0;
            for (let c of fromEnum(this.dj.a)) {
                this.f.bc.exportPathData(a, c, "column" + b, ["Main", "Fill"]);
                b++;
            }
        }
        dp() {
            this.a2();
        }
    }
    RadialColumnSeriesView.$t = markType(RadialColumnSeriesView, 'RadialColumnSeriesView', AnchoredRadialSeriesView.$);
    return RadialColumnSeriesView;
})();
