/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { AnchoredRadialSeries } from "./AnchoredRadialSeries";
import { DependencyProperty } from "igniteui-react-core";
import { Defaults } from "./Defaults";
import { Point_$type, runOn, typeCast, markType, markDep, fromEnum } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { RadialBaseView } from "./RadialBaseView";
import { List$1 } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-react-core";
import { PathFigure } from "igniteui-react-core";
import { PolyLineSegment } from "igniteui-react-core";
import { ViewportUtils } from "./ViewportUtils";
import { ChartSelection } from "./ChartSelection";
import { Clipper } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView";
/**
 * @hidden
 */
export let RadialColumnSeries = /*@__PURE__*/ (() => {
    class RadialColumnSeries extends AnchoredRadialSeries {
        bj() {
            return new RadialColumnSeries();
        }
        get_ez() {
            return true;
        }
        get_fl() {
            return true;
        }
        jk() {
            if (!isNaN_(this.jj)) {
                return super.jk();
            }
            return Defaults.h;
        }
        cs() {
            return new RadialColumnSeriesView(this);
        }
        qz(a) {
            super.qz(a);
            this.adn = a;
        }
        constructor() {
            super();
            this.ab = RadialColumnSeries.$;
        }
        ac() {
            super.ac();
            this.rp(false);
        }
        q7(a, b, c, d) {
            super.q7(a, b, c, d);
            switch (b) {
                case RadialColumnSeries.$$p[0]:
                case RadialColumnSeries.$$p[1]:
                    this.q1();
                    break;
            }
        }
        preferredCategoryMode(a) {
            return a != null && a == this.yx ? 2 : 0;
        }
        o5(a, b) {
            super.o5(a, b);
            let c = b;
            if (a) {
                c.c6.count = 0;
            }
        }
        get_ed() {
            return true;
        }
        iw() {
            return this.yx.k8(this.cv.by, this.cv.bx, this.getEffectiveViewport1(this.cv));
        }
        aba(a, b) {
            super.aba(a, b);
            let c = a.f;
            let d = b.by;
            let e = b.bx;
            let f = this.getEffectiveViewport1(b);
            let g = this.wh(b);
            let h = this.y3.k5(e, d, f, g);
            let i = b;
            let j = this.y3;
            let k = Math.max(0, 0.5 * j.n6);
            k = Math.max(k, h.minLength * 0.9);
            let l = ViewportUtils.d(k, d, e, f);
            let m = this.yx.k8(d, e, f);
            let n = Math.max(0.1 * this.y3.n7, k);
            let o = this.y6.d(0, n, d, e, f);
            let p = this.y6.e(0, n, d, e, f);
            let q = this.y6.d(m, n, d, e, f);
            let r = this.y6.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.ab6.count;
            this.ze.a2(this, this.zv(), runOn(this, this.yl), this.z4(b), this.z5(b));
            this.ze.r = this.ado;
            this.ze.s = this.adp;
            this.ze.k = this.ado;
            this.ze.l = this.adp;
            let v = false;
            let w = this.ze.b;
            if (w != null) {
                v = true;
            }
            let x = this.yx;
            let y = new ScalerParams(1, b.by, b.bx, x.ch);
            y.c = this.getEffectiveViewport();
            for (let z = 0; z < c.count; ++z) {
                let aa = Math.min(a.f._inner[z][2], h.maxLength * 1.1);
                let ab = this.y6.d(a.f._inner[z][0], aa, d, e, f);
                let ac = this.y6.e(a.f._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.ac3(c, z, u, x, y, b.q);
                }
                let ag = this.ze.k;
                let ah = this.ze.l;
                let ai = a.f._inner[z][0] - (Math.PI / 2);
                let aj = i.c6.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.ze.ad(aj, false, false, false, false);
            }
            i.c6.count = c.count;
            this.adn.db();
        }
        ak(a, b) {
            let c = new List$1(ChartSelection.$, 0);
            this.p2(a, c, b);
            return c.toArray();
        }
        p2(a, b, c) {
            if (this.yy == 0) {
                super.p2(a, b, c);
                return;
            }
            let d = this.cv.by;
            let e = this.cv.bx;
            let f = this.getEffectiveViewport1(this.cv);
            let g = this.wh(this.cv);
            let h = this.y3.k5(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 = new Clipper(1, a.left, a.bottom, a.right, a.top, true);
            let k = this.y3;
            let l = Math.max(0, 0.5 * k.n6);
            l = Math.max(l, h.minLength * 0.9);
            let m = ViewportUtils.d(l, d, e, f);
            let n = this.yx.k8(d, e, f);
            let o = Math.max(0.1 * this.y3.n7, l);
            let p = this.y6.d(0, o, d, e, f);
            let q = this.y6.e(0, o, d, e, f);
            let r = this.y6.d(n, o, d, e, f);
            let s = this.y6.e(n, o, d, e, f);
            let t = Math.sqrt((p - r) * (p - r) + (q - s) * (q - s));
            let u = this.yx != null && this.yx.cl;
            for (let v = 0; v < this.yx.lk; v++) {
                let w = typeCast(RadialBaseView.$, this.cv);
                let x = w.cx.getBucket(v);
                let y = Math.min(this.y6.b.od(x[2]), h.maxLength * 1.1);
                let z = this.ach(this.yx, d, e, f);
                if (u) {
                    z = this.acg(v, this.yx, d, e, f);
                    if (isNaN_(z)) {
                        z = 0;
                    }
                }
                x[0] = this.yx.getScaledAngle(x[0]) + z;
                let aa = this.y6.d(x[0], y, d, e, f);
                let ab = this.y6.e(x[0], y, d, e, f);
                let ac = Math.sqrt((aa - i.x) * (aa - i.x) + (ab - i.y) * (ab - i.y));
                let ad = ac;
                let ae = m;
                let af = x[0] - (Math.PI / 2);
                let ag = 0 - (t / 2);
                let ah = (t / 2);
                let ai = Math.max(ae, ad);
                let aj = Math.min(ae, ad);
                let ak = Math.cos(af);
                let al = Math.sin(af);
                let am = { $type: Point_$type, x: i.x + (ag * ak - ai * al), y: i.y + (ag * al + ai * ak) };
                let an = { $type: Point_$type, x: i.x + (ah * ak - ai * al), y: i.y + (ah * al + ai * ak) };
                let ao = { $type: Point_$type, x: i.x + (ah * ak - aj * al), y: i.y + (ah * al + aj * ak) };
                let ap = { $type: Point_$type, x: i.x + (ag * ak - aj * al), y: i.y + (ag * al + aj * ak) };
                let aq = new List$1(Point_$type, 0);
                j.i = aq;
                j.j(am);
                j.j(an);
                j.j(ao);
                j.j(ap);
                j.i = null;
                if (aq == null || aq.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.dn.item(v);
                        return $ret;
                    })()));
                }
                else {
                    b.add(((() => {
                        let $ret = new ChartSelection();
                        $ret.item = this.dn.item(v);
                        $ret.series = this;
                        return $ret;
                    })()));
                }
            }
        }
    }
    RadialColumnSeries.$t = /*@__PURE__*/ markType(RadialColumnSeries, 'RadialColumnSeries', AnchoredRadialSeries.$);
    RadialColumnSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, RadialColumnSeries, 'raisePropertyChanged', ['RadiusX:ado:ads', [1, 0], 'RadiusY:adp:adt', [1, 0]]);
    return RadialColumnSeries;
})();
/**
 * @hidden
 */
export let RadialColumnSeriesView = /*@__PURE__*/ (() => {
    class RadialColumnSeriesView extends AnchoredRadialSeriesView {
        constructor(a) {
            super(a);
            this.c5 = null;
            this.c6 = null;
            this.c7 = null;
            this.dd = new Path();
            this.c5 = a;
            this.c6 = ((() => {
                let $ret = new Pool$1(Path.$);
                $ret.create = runOn(this, this.de);
                $ret.activate = runOn(this, this.c8);
                $ret.disactivate = runOn(this, this.da);
                $ret.destroy = runOn(this, this.c9);
                return $ret;
            })());
        }
        au() {
            super.au();
            this.c7 = new List$1(Path.$, 0);
            if (!this.q) {
                this.cw.w8 = Defaults.c;
                this.cw.jp = Defaults.i;
            }
        }
        de() {
            let a = new Path();
            this.c7.add(a);
            a._visibility = 1;
            return a;
        }
        c8(a) {
            a._visibility = 0;
        }
        da(a) {
            a._visibility = 1;
        }
        c9(a) {
            this.c7.remove(a);
        }
        dc(a, b, c, d, e, f) {
            this.as();
        }
        bg(a, b) {
            super.bg(a, b);
            let c = a;
        }
        bh(a, b) {
            super.bh(a, b);
            let c = a;
        }
        ac(a) {
            return this.c7._inner[a];
        }
        ab(a) {
            let b = this.c7._inner[a];
            this.dd._visibility = b._visibility;
            this.dd.an = b.an;
            let c = this.bs(a);
            this.dd._fill = c;
            this.dd._stroke = c;
            this.dd.ad = this.e.ie + 3;
            return this.dd;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                for (let c = 0; c < this.c7.count; c++) {
                    let d = this.aa(c, b);
                    this.bf(d, c, b);
                    a.t(d);
                }
            }
        }
        an(a) {
            super.an(a);
            let b = 0;
            for (let c of fromEnum(this.c6.a)) {
                this.e.bc.exportPathData(a, c, "column" + b, ["Main", "Fill"]);
                b++;
            }
        }
        db() {
            this.as();
        }
    }
    RadialColumnSeriesView.$t = /*@__PURE__*/ markType(RadialColumnSeriesView, 'RadialColumnSeriesView', AnchoredRadialSeriesView.$);
    return RadialColumnSeriesView;
})();
