/*
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/ES2015/DependencyProperty";
import { Type, Point_$type, markType, runOn, fromEnum } from "igniteui-react-core/ES2015/type";
import { Pool$1 } from "igniteui-react-core/ES2015/Pool$1";
import { Path } from "igniteui-react-core/ES2015/Path";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { PathGeometry } from "igniteui-react-core/ES2015/PathGeometry";
import { PathFigure } from "igniteui-react-core/ES2015/PathFigure";
import { PolyLineSegment } from "igniteui-react-core/ES2015/PolyLineSegment";
import { ViewportUtils } from "./ViewportUtils";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
import { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView";
/**
 * @hidden
 */
export class RadialColumnSeries extends AnchoredRadialSeries {
    constructor() {
        super();
        this.ab = RadialColumnSeries.$;
    }
    bf() {
        return new RadialColumnSeriesView(this);
    }
    im(a) {
        super.im(a);
        this.oj = a;
    }
    ac() {
        super.ac();
        this.i6(false);
    }
    preferredCategoryMode(a) {
        return a != null && a == this.mt ? 2 : 0;
    }
    hp(a, b) {
        super.hp(a, b);
        let c = b;
        if (a) {
            c.cx.count = 0;
        }
    }
    ed() {
        return this.mt.jk(this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi));
    }
    ne(a, b) {
        super.ne(a, b);
        let c = a.f;
        let d = b.bs;
        let e = b.br;
        let f = this.getEffectiveViewport1(b);
        let g = this.lj(b);
        let h = this.mv.i9(e, d, f, g);
        let i = b;
        let j = this.mv;
        let k = Math.max(0, 0.5 * j.lb);
        k = Math.max(k, h.minLength * 0.9);
        let l = ViewportUtils.d(k, d, e);
        let m = this.mt.jk(d, e, f);
        let n = Math.max(0.1 * this.mv.lc, k);
        let o = this.mw.d(0, n, d, e);
        let p = this.mw.e(0, n, d, e);
        let q = this.mw.d(m, n, d, e);
        let r = this.mw.e(m, n, d, e);
        let s = Math.sqrt((o - q) * (o - q) + (p - r) * (p - r));
        let t = { $type: Point_$type, x: ViewportUtils.c(0.5, d, e), y: ViewportUtils.f(0.5, d, e) };
        for (let u = 0; u < c.count; ++u) {
            let v = Math.min(a.f._inner[u][2], h.maxLength * 1.1);
            let w = this.mw.d(a.f._inner[u][0], v, d, e);
            let x = this.mw.e(a.f._inner[u][0], v, d, e);
            let y = Math.sqrt((w - t.x) * (w - t.x) + (x - t.y) * (x - t.y));
            let z = y;
            let aa = l;
            let ab = a.f._inner[u][0] - (Math.PI / 2);
            let ac = i.cx.item(u);
            let ad = 0 - (s / 2);
            let ae = (s / 2);
            let af = Math.max(aa, z);
            let ag = Math.min(aa, z);
            let ah = Math.cos(ab);
            let ai = Math.sin(ab);
            let aj = { $type: Point_$type, x: t.x + (ad * ah - af * ai), y: t.y + (ad * ai + af * ah) };
            let ak = { $type: Point_$type, x: t.x + (ae * ah - af * ai), y: t.y + (ae * ai + af * ah) };
            let al = { $type: Point_$type, x: t.x + (ae * ah - ag * ai), y: t.y + (ae * ai + ag * ah) };
            let am = { $type: Point_$type, x: t.x + (ad * ah - ag * ai), y: t.y + (ad * ai + ag * ah) };
            let an = new PathGeometry();
            let ao = new PathFigure();
            ao._startPoint = aj;
            ao._isClosed = true;
            let ap = new PolyLineSegment();
            ap._points.add(ak);
            ap._points.add(al);
            ap._points.add(am);
            ao._segments.add(ap);
            an.b.add(ao);
            ac.aj = an;
        }
        i.cx.count = c.count;
        this.oj.c2();
    }
}
RadialColumnSeries.$t = markType(RadialColumnSeries, 'RadialColumnSeries', AnchoredRadialSeries.$);
Type.dep(DependencyProperty, PropertyMetadata, RadialColumnSeries, 'raisePropertyChanged', ['RadiusX:ok:oo', [1, 2], 'RadiusY:ol:op', [1, 2]]);
/**
 * @hidden
 */
export class RadialColumnSeriesView extends AnchoredRadialSeriesView {
    constructor(a) {
        super(a);
        this.cw = null;
        this.cx = null;
        this.cy = null;
        this.cw = a;
        this.cx = ((() => {
            let $ret = new Pool$1(Path.$);
            $ret.create = runOn(this, this.c4);
            $ret.activate = runOn(this, this.cz);
            $ret.disactivate = runOn(this, this.c1);
            $ret.destroy = runOn(this, this.c0);
            return $ret;
        })());
    }
    ap() {
        super.ap();
        this.cy = new List$1(Path.$, 0);
        if (!this.n) {
            this.e.er = 4;
            this.e.bj = 1;
        }
    }
    c4() {
        let a = new Path();
        this.cy.add(a);
        a._visibility = 1;
        return a;
    }
    cz(a) {
        a._visibility = 0;
    }
    c1(a) {
        a._visibility = 1;
    }
    c0(a) {
        this.cy.remove(a);
    }
    c3(a, b, c, d, e, f) {
        this.an();
    }
    bb(a, b) {
        super.bb(a, b);
        let c = a;
        c._fill = this.e.kw;
        c._stroke = this.e.kx;
        c.ac = this.e.ev;
        c.ai = this.e.k4;
        c.ad = this.e.k5;
    }
    bc(a, b) {
        super.bc(a, b);
        let c = a;
        let d = this.bm(b);
        c._fill = d;
        c._stroke = d;
        c.ac = this.e.ev + 3;
    }
    a3(a, b) {
        super.a3(a, b);
        if (a.d) {
            for (let c = 0; c < this.cy.count; c++) {
                let d = this.cy._inner[c];
                this.ba(d, c, b);
                a.s(d);
            }
        }
    }
    ai(a) {
        super.ai(a);
        let b = 0;
        for (let c of fromEnum(this.cx.a)) {
            this.e.a2.exportPathData(a, c, "column" + b, ["Main", "Fill"]);
            b++;
        }
    }
    c2() {
        this.an();
    }
}
RadialColumnSeriesView.$t = markType(RadialColumnSeriesView, 'RadialColumnSeriesView', AnchoredRadialSeriesView.$);
