/*
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 { Series } from "./Series";
import { DependencyProperty } from "igniteui-angular-core";
import { HighlightingInfo } from "./HighlightingInfo";
import { ShapeItemSearchMode_$type } from "./ShapeItemSearchMode";
import { IEnumerable$1_$type, enumGetBox, Number_$type, Point_$type, typeCast, fromEnum, runOn, Array_$type, markType, markDep } from "igniteui-angular-core";
import { NumericXAxis } from "./NumericXAxis";
import { NumericYAxis } from "./NumericYAxis";
import { List$1 } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { StyleShapeEventArgs } from "./StyleShapeEventArgs";
import { FrameworkElement } from "igniteui-angular-core";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { DataContext } from "igniteui-angular-core";
import { Tuple$2 } from "igniteui-angular-core";
import { ShapeHitRegion } from "./ShapeHitRegion";
import { RectUtil } from "igniteui-angular-core";
import { Tuple$3 } from "igniteui-angular-core";
import { GeometryUtil } from "igniteui-angular-core";
import { AssigningShapeStyleEventArgs } from "./AssigningShapeStyleEventArgs";
import { AssigningShapeMarkerStyleEventArgs } from "./AssigningShapeMarkerStyleEventArgs";
import { PointCollectionUtil } from "igniteui-angular-core";
import { FlattenedShape } from "./FlattenedShape";
import { SeriesView } from "./SeriesView";
import { Clipper } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { Dictionary$2 } from "igniteui-angular-core";
import { SeriesRenderManager } from "./SeriesRenderManager";
import { PolySimplification } from "igniteui-angular-core";
import { DefaultFlattener } from "./DefaultFlattener";
import { AxisRange } from "./AxisRange";
import { Style } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { boxArray$1 } from "igniteui-angular-core";
import { InvalidOperationException } from "igniteui-angular-core";
import { isNaN_, truncate } from "igniteui-angular-core";
import { FastItemObjectColumn } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { PointCollection } from "igniteui-angular-core";
import { PathGeometry } from "igniteui-angular-core";
import { PolyLineSegment } from "igniteui-angular-core";
import { PathFigure } from "igniteui-angular-core";
import { PolygonUtil } from "igniteui-angular-core";
/**
 * @hidden
 */
export let ShapeSeriesBase = /*@__PURE__*/ (() => {
    class ShapeSeriesBase extends Series {
        constructor() {
            super();
            this.q1 = false;
            this.q0 = false;
            this.qm = null;
            this.qn = null;
            this.qs = 1;
            this.qc = null;
            this.qd = null;
            this.assigningShapeStyle = null;
            this.assigningShapeMarkerStyle = null;
            this.qw = null;
            this.qy = null;
            this.qo = null;
            this.qq = null;
            this.rl = 0;
            this.rh = null;
            this.p9 = null;
            this.qb = null;
            this.qa = null;
            this.p8 = null;
            this.ss = null;
            this.ro = 0;
            this.styleShape = null;
            this.qw = new ShapeSeriesRenderManager();
            FastItemObjectColumn.m();
            this.ro = this.rn;
            this.ss = Rect.empty;
        }
        kx() {
            super.kx();
            this.qp = null;
            this.qr = null;
        }
        ag() {
            return [this.qp, this.qr];
        }
        hy(a, b) {
            let c = this.js(b);
            if (c == ShapeSeriesBase.$$p[6]) {
                return this.hz(a, b, this.r1);
            }
            return null;
        }
        get_dy() {
            return true;
        }
        get_c2() {
            return true;
        }
        qk(a, b, c) {
            let d = this.pl(b);
            let e = this.qx.cz(d, false);
            let f = -1;
            if (e == null) {
                if (a != null) {
                    f = this.ck.indexOf(a);
                }
                else {
                    return null;
                }
            }
            else if (e.dataContext != null) {
                f = e.dataContext.c;
            }
            if (f == -1) {
                return null;
            }
            let g = new HighlightingInfo();
            g.b = this;
            g.h = f;
            g.g = f;
            g.d = false;
            if (c != null && c.h == g.h && c.g == g.g) {
                return c;
            }
            return g;
        }
        ql(a, b, c) {
            let d = this.qx.b1(this.pl(b));
            let e = -1;
            if (d == null) {
                if (a != null) {
                    e = this.ck.indexOf(a);
                }
                else {
                    return null;
                }
            }
            else {
                e = d.ak;
            }
            if (e == -1) {
                return null;
            }
            let f = new HighlightingInfo();
            f.b = this;
            f.h = e;
            f.g = e;
            f.d = false;
            f.e = true;
            if (c != null && c.h == f.h && c.g == f.g) {
                return c;
            }
            return f;
        }
        get qt() {
            return this.qs;
        }
        set qt(a) {
            let b = this.qs;
            this.qs = a;
            if (b != this.qs) {
                this.raisePropertyChanged("ActualItemSearchMode", enumGetBox(ShapeItemSearchMode_$type, b), enumGetBox(ShapeItemSearchMode_$type, this.qs));
            }
        }
        qu() {
            if (this.qv != 0) {
                return this.qv;
            }
            return 1;
        }
        f7(a) {
            switch (this.qt) {
                case 1: return this.r7(a).c;
                case 2: return this.rm(a);
                case 3: return this.rm(a);
            }
            return -1;
        }
        r7(a) {
            let b = this.pl(a);
            let c = { $type: Point_$type, x: NaN, y: NaN };
            let d = this.qx.cb;
            if (d == null) {
                return new Tuple$2(Number_$type, Point_$type, -1, c);
            }
            let e = this.qx.b2(b, false, !this.q2);
            if (e != null) {
                c = RectUtil.l(e.d);
                return new Tuple$2(Number_$type, Point_$type, e.b, c);
            }
            let f = b.x;
            let g = b.y;
            if (this.ck == null || this.qp == null || this.qr == null || this.rh == null) {
                return new Tuple$2(Number_$type, Point_$type, -1, c);
            }
            if (this.ck.count > this.rr) {
                return new Tuple$2(Number_$type, Point_$type, -1, c);
            }
            let h = 1.7976931348623157E+308;
            let i = -1;
            for (let j = 0; j < d.count; j++) {
                let k = d._inner[j].d;
                let l = RectUtil.g(k, b);
                if (l < h) {
                    h = l;
                    i = d._inner[j].b;
                    c = RectUtil.l(d._inner[j].d);
                }
            }
            return new Tuple$2(Number_$type, Point_$type, i, c);
        }
        r6(a) {
            let b = this.pl(a);
            let c = b.x;
            let d = b.y;
            let e = { $type: Point_$type, x: NaN, y: NaN };
            if (this.ck == null || this.qp == null || this.qr == null || this.rh == null) {
                return new Tuple$3(Number_$type, Point_$type, Point_$type, -1, e, e);
            }
            if (this.ck.count > this.rr) {
                return new Tuple$3(Number_$type, Point_$type, Point_$type, -1, e, e);
            }
            let f = 1.7976931348623157E+308;
            let g = this.qx.cb;
            if (g == null) {
                return new Tuple$3(Number_$type, Point_$type, Point_$type, -1, e, e);
            }
            let h = this.qx.b2(b, false, !this.q2);
            if (h != null) {
                let i = RectUtil.l(h.d);
                let j = this.r5(b, h.a, this.q2);
                return new Tuple$3(Number_$type, Point_$type, Point_$type, h.b, j.d, i);
            }
            for (let k = 0; k < g.count; k++) {
                let l = g._inner[k].d;
                let m = RectUtil.g(l, b);
                let n = (l.width * l.width) + (l.height * l.height) + m;
                if (n <= f) {
                    f = n;
                }
            }
            let o = 1.7976931348623157E+308;
            let p = -1;
            for (let q = 0; q < g.count; q++) {
                let r = g._inner[q].d;
                let s = RectUtil.g(r, b);
                if (s < f) {
                    let t = this.r5(b, g._inner[q].a, this.q2);
                    if (t.c < o) {
                        o = t.c;
                        e = t.d;
                        p = q;
                    }
                }
            }
            if (p >= 0) {
                return new Tuple$3(Number_$type, Point_$type, Point_$type, g._inner[p].b, e, RectUtil.l(g._inner[p].d));
            }
            return new Tuple$3(Number_$type, Point_$type, Point_$type, -1, e, e);
        }
        get_q2() {
            return true;
        }
        get q2() {
            return this.get_q2();
        }
        r5(a, b, c) {
            let d = { $type: Point_$type, x: NaN, y: NaN };
            let e = 1.7976931348623157E+308;
            let f = { $type: Point_$type, x: NaN, y: NaN };
            let g = false;
            let h = -1;
            for (let i = 0; i < b.count; i++) {
                let j = b._inner[i];
                if (i >= 1) {
                    let k = GeometryUtil.d(a, d, j);
                    if (k < e) {
                        e = k;
                        g = true;
                        h = i;
                    }
                }
                d = j;
            }
            if (c) {
                let l = b._inner[0];
                let m = GeometryUtil.d(a, d, l);
                if (m < e) {
                    e = m;
                    let n = GeometryUtil.h(a, d, l);
                    f = { $type: Point_$type, x: d.x + (l.x - d.x) * n, y: d.y + (l.y - d.y) * n };
                    return new Tuple$2(Number_$type, Point_$type, e, f);
                }
            }
            if (g) {
                let o = b._inner[h - 1];
                let p = b._inner[h];
                let q = GeometryUtil.h(a, o, p);
                f = { $type: Point_$type, x: o.x + (p.x - o.x) * q, y: o.y + (p.y - o.y) * q };
            }
            return new Tuple$2(Number_$type, Point_$type, e, f);
        }
        rm(a) {
            return this.r6(a).c;
        }
        pq(a, b, c) {
            if (this.qp == null || this.qr == null || this.rh == null) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            switch (this.qt) {
                case 1:
                    let d = this.r7(a);
                    return d.d;
                case 2:
                    let e = this.r6(a);
                    return e.e;
                case 3:
                    let f = this.r6(a);
                    return f.d;
            }
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        hv(a) {
            let b = this.hf(a);
            if (this.ck != null && b >= 0 && b < this.ck.count) {
                return this.ck.item(b);
            }
            return null;
        }
        qj(a, b, c) {
            let d = new HighlightingInfo();
            d.b = this;
            d.h = 0;
            d.g = this.ck.count - 1;
            d.d = true;
            if (c != null && c.h == d.h && c.g == d.g) {
                return c;
            }
            return d;
        }
        aw(a, b, c) {
            if (this.c2 && this.eg(this.bk) && !c) {
                let d = this.qk(a, b, this.qm);
                this.qm = d;
                return d;
            }
            else {
                let e = this.qj(a, b, this.qm);
                this.qm = e;
                return e;
            }
        }
        ax(a, b, c) {
            if (this.eg(this.bk) && !c) {
                let d = this.ql(a, b, this.qn);
                this.qn = d;
                return d;
            }
            else {
                let e = this.qj(a, b, this.qn);
                e.e = true;
                this.qn = e;
                return e;
            }
        }
        rf() {
            return (this.assigningShapeStyle != null && this.q1) || (this.bk != 1);
        }
        re() {
            return (this.assigningShapeMarkerStyle != null && this.q0) || (this.bk != 1);
        }
        get qz() {
            return this.qy;
        }
        set qz(a) {
            let b = this.qz != a;
            if (b) {
                let c = this.qz;
                this.qy = a;
                this.raisePropertyChanged("ShapeColumn", c, this.qz);
            }
        }
        q6(array_) {
            let a = (Array.isArray(array_));
            return a;
        }
        static ra(a) {
            if (a == null) {
                return true;
            }
            let val_ = a;
            return (val_ == undefined);
        }
        convertToListList(a) {
            if (a == null) {
                return null;
            }
            let b = new List$1(List$1.$.specialize(Point_$type), 0);
            let c;
            let curr_;
            let d;
            let e;
            let f = false;
            let g = false;
            for (let h = 0; h < a.length; h++) {
                c = a[h];
                if (c == null) {
                    continue;
                }
                let i = new List$1(Point_$type, 0);
                for (let j = 0; j < c.length; j++) {
                    curr_ = c[j];
                    if (f) {
                        d = (curr_.X);
                        e = (curr_.Y);
                    }
                    else {
                        d = (curr_.x);
                        e = (curr_.y);
                    }
                    if (!g) {
                        if ((isNaN_(d) || ShapeSeriesBase.ra(d)) && (isNaN_(e) || ShapeSeriesBase.ra(e))) {
                            d = (curr_.X);
                            e = (curr_.Y);
                            if (!isNaN_(d) && !ShapeSeriesBase.ra(d) && !isNaN_(e) && !ShapeSeriesBase.ra(e)) {
                                g = true;
                                f = true;
                            }
                        }
                        else {
                            g = true;
                        }
                    }
                    i.add({ $type: Point_$type, x: d, y: e });
                }
                b.add(i);
            }
            return b;
        }
        cj(a) {
            if (this.ck != null && this.q6(this.itemsSource) && a != null && a.split('!').length != 2) {
                if (this.coercionMethods == null) {
                    this.coercionMethods = {};
                }
                let methods_ = this.coercionMethods;
                methods_.convertToListList = this.convertToListList;
                a += "!convertToListList";
            }
            return super.cj(a);
        }
        l7(a, b, c, d) {
            super.l7(a, b, c, d);
            let e = false;
            let f = false;
            switch (b) {
                case ShapeSeriesBase.$$p[2]:
                    this.qt = this.qu();
                    break;
                case "FastItemsSource":
                    let g = typeCast(IFastItemsSource_$type, c);
                    if (g != null) {
                        g.deregisterColumn(this.qz);
                        this.qz = null;
                    }
                    let h = typeCast(IFastItemsSource_$type, d);
                    if (h != null) {
                        this.qz = this.cj(this.r1);
                    }
                    e = this.qp != null && !this.qp.c0();
                    f = this.qr != null && !this.qr.c0();
                    if (e || f) {
                        this.ml(false);
                    }
                    break;
                case ShapeSeriesBase.$$p[6]:
                    if (this.ck != null) {
                        this.ck.deregisterColumn(this.qz);
                        this.qz = this.cj(this.r1);
                    }
                    break;
                case "ShapeColumn":
                    this.sg();
                    e = this.qp != null && !this.qp.c0();
                    f = this.qr != null && !this.qr.c0();
                    if (e || f) {
                        this.ml(false);
                    }
                    this.ls();
                    break;
                case ShapeSeriesBase.$$p[7]:
                case ShapeSeriesBase.$$p[8]:
                    this.qo = this.qp;
                    this.qq = this.qr;
                    let i = c;
                    let j = d;
                    this.sh(i);
                    this.r9(j);
                    if ((j != null && !j.c0()) || (j == null && i != null)) {
                        this.ml(false);
                    }
                    this.ls();
                    break;
                case "ActualResolution":
                    this.rl = this.fv;
                    this.ls();
                    break;
                case "ActualBrush":
                    this.ml(false);
                    break;
                case ShapeSeriesBase.$$p[5]:
                    this.ro = this.rn;
                    this.ml(false);
                    this.ls();
                    break;
                case "ActualThickness":
                    this.ml(false);
                    this.ls();
                    break;
                case ShapeSeriesBase.$$p[1]:
                    this.q1 = this.rd();
                    this.ml(false);
                    break;
                case ShapeSeriesBase.$$p[0]:
                    this.q0 = this.rc();
                    this.ml(false);
                    break;
            }
        }
        rd() {
            return this.q9;
        }
        rc() {
            return this.q8;
        }
        q4(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        q3(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        sg() {
            this.rh = null;
            if (this.qz == null) {
                return;
            }
            this.rh = new List$1(Rect.$, 2, this.qz.count);
            for (let a = 0; a < this.qz.count; a++) {
                this.rh.add(PointCollectionUtil.j(this.qz.item(a)));
            }
        }
        st(a) {
            if (typeCast(IEnumerable$1_$type.specialize(IEnumerable$1_$type.specialize(Point_$type)), a) !== null) {
                return PointCollectionUtil.h(a);
            }
            else if (typeCast(IEnumerable$1_$type.specialize(Point_$type), a) !== null) {
                return PointCollectionUtil.g(a);
            }
            return Rect.empty;
        }
        rj(a, b, c, d, e, f, g) {
            return this.rk(a, b, c, d, e, f, g);
            if (typeCast(List$1.$.specialize(List$1.$.specialize(Point_$type)), c) !== null) {
                return this.rk(a, b, c, d, e, f, g);
            }
            else if (typeCast(IEnumerable$1_$type.specialize(IEnumerable$1_$type.specialize(Point_$type)), c) !== null) {
                let h = c;
                let i = new List$1(FlattenedShape.$, 0);
                let j = null;
                for (let k of fromEnum(h)) {
                    j = this.qi(a, b, PointCollectionUtil.b(k), d, e, f, g);
                    if (j == null) {
                        continue;
                    }
                    i.add(j);
                }
                return i;
            }
            else if (typeCast(IEnumerable$1_$type.specialize(Point_$type), c) !== null) {
                let l = c;
                let m = this.qi(a, b, PointCollectionUtil.b(l), d, e, f, g);
                let n = new List$1(FlattenedShape.$, 0);
                if (m != null) {
                    n.add(m);
                }
                return n;
            }
            else {
                throw new InvalidOperationException(1, "Unrecognized data in ShapeColumn");
            }
        }
        get_q7() {
            return true;
        }
        get q7() {
            return this.get_q7();
        }
        rg() {
            return false;
        }
        mm(a) {
            this.sf(this.b0);
        }
        mk(a, b, c, d, e) {
            super.mk(a, b, c, d, e);
            let f = this.a6.a$h.item(d);
            let g = f;
            f.a1(c);
            if (this.cx(f)) {
                return;
            }
            this.sf(f);
        }
        sf(a) {
            if (this.cx(a)) {
                return;
            }
            let b;
            let c;
            let d = a;
            let e = a.getViewInfo(c, b);
            c = e.p0;
            b = e.p1;
            if (c.width < 1 || c.height < 1 || this.qz == null) {
                return;
            }
            let f = this.qp;
            let g = this.qr;
            let h = this.getEffectiveViewport1(a);
            let i = new ScalerParams(1, b, c, f.cg);
            i.c = h;
            let j = new ScalerParams(1, b, c, g.cg);
            j.c = h;
            if (!this.eu) {
                d.cr();
                let k = new Rect(0, 0, 0, 0, 0);
                let l;
                let m;
                let n;
                let o;
                let p = this.qz.count;
                if (this.qb == null || this.qb.length != p) {
                    this.qb = new Array(p);
                    this.p9 = new Array(p);
                    this.qa = new Array(p);
                    this.p8 = new Array(p);
                }
                let q = this.qb;
                let r = this.p9;
                let s = this.qa;
                let t = this.p8;
                let u;
                for (let v = 0; v < p; v++) {
                    u = this.rh._inner[v];
                    q[v] = u.top;
                    r[v] = u.left;
                    s[v] = u.right;
                    t[v] = u.bottom;
                }
                this.qo.hm(boxArray$1(r), 0, r.length, i);
                this.qo.hm(boxArray$1(s), 0, s.length, i);
                this.qq.hm(boxArray$1(q), 0, q.length, j);
                this.qq.hm(boxArray$1(t), 0, t.length, j);
                d.cs(r, q, s, t);
                let w = this.qz;
                let x = this.ck;
                this.si(d);
                let y = c.left;
                let z = c.right;
                let aa = c.top;
                let ab = c.bottom;
                let ac = null;
                if (this.ss.isEmpty) {
                    ac = null;
                }
                else {
                    ac = new Clipper(1, this.ss.left, this.ss.bottom, this.ss.right, this.ss.top, this.q7);
                }
                let ad = this.rg();
                if (ad) {
                    d.b9.clear();
                }
                let ae = false;
                let af = true;
                let ag = 0;
                if (this.cd != null) {
                    if (this.cd.e8()) {
                        let ah = this.cd.lh(b, i);
                        ae = ah.c;
                        ag = ah.d;
                    }
                }
                let ai;
                for (let aj = 0; aj < p; aj++) {
                    n = r[aj];
                    l = q[aj];
                    m = t[aj];
                    o = s[aj];
                    k.x = Math.min(n, o);
                    k.y = Math.min(l, m);
                    k.width = Math.max(n, o) - k.x;
                    k.height = Math.max(l, m) - k.y;
                    if (k.intersectsWith(c)) {
                        if (k.x < y || k.y < aa || k.x > z || k.y > ab) {
                            ai = ac;
                        }
                        else {
                            ai = null;
                        }
                        let ak = this.rj(a, ai, w.item(aj), i, j, 0, ag);
                        if (ad) {
                            ShapeSeriesBase.se(d, aj, ak);
                        }
                        d.cf(aj, x.item(aj), k, ak);
                    }
                    else if (ae) {
                        k.x = k.x + ag;
                        if (k.intersectsWith(c)) {
                            if (k.x < y || k.y < aa || k.x > z || k.y > ab) {
                                ai = ac;
                            }
                            else {
                                ai = null;
                            }
                            let al = this.rj(a, ai, w.item(aj), i, j, ag, ag);
                            if (ad) {
                                ShapeSeriesBase.se(d, aj, al);
                            }
                            d.cf(aj, x.item(aj), k, al);
                        }
                    }
                }
                d.cq();
            }
            let am = this.rf();
            this.qw.ax(this, this.rf(), runOn(this, this.qe));
            let an = false;
            let ao = this.qw.b;
            if (ao != null) {
                an = true;
            }
            let ap = a.q;
            let aq = this.ef;
            let ar = d.b7;
            d.cm((as) => {
                let at = as.dataContext != null ? as.dataContext.item : null;
                let au = as.dataContext != null ? as.dataContext.c : -1;
                d.cj(as, at, am);
                if (an) {
                    this.sb(as, aq, au, this.qz.count, ap, ar);
                }
                else {
                    if (ar) {
                        {
                            this.qw.az(as, this.ft, ar);
                        }
                    }
                }
                {
                    this.qw.ad(as, false, false, false, false);
                }
            });
        }
        sb(a, b, c, d, e, f) {
            let g = this.bk != 1;
            this.qw.ay(this.qw.b, c, d, false);
            {
                this.qw.az(a, this.ft, f);
            }
            let h = this.qw.av;
            let i = null;
            let j = this.ck;
            if (g && this.cd != null) {
                i = this.cd.a7.getHighlightingInfo(this, j, h.o, h.n, false);
                h.b = i;
            }
            h.f = e;
            this.sd(h);
            this.qw.z(this, i, e, g, false);
        }
        sa(a, b, c) {
            let d = this.bk != 1;
            this.qw.ay(this.qw.d, a, b, true);
            this.qw.aa(this.ft);
            let e = this.qw.au;
            let f = null;
            let g = this.ck;
            let h = null;
            if (d && this.cd != null) {
                f = this.cd.a7.getHighlightingInfo(this, g, e.o, e.n, true);
                if (this.cd.a7.isCrossSeriesHighlight(this)) {
                    h = this.cd.a7.getHighlightingInfo(this, g, e.o, e.n, true);
                }
                e.b = f;
            }
            e.f = c;
            this.sc(e);
            this.qw.y(this, f, c, d, e.l, this.cd.a7.sumHighlightingProgress);
        }
        sd(a) {
            if (this.assigningShapeStyle != null && this.q1) {
                this.assigningShapeStyle(this, a);
            }
        }
        sc(a) {
            if (this.assigningShapeMarkerStyle != null && this.q0) {
                this.assigningShapeMarkerStyle(this, a);
            }
        }
        qe(a, b) {
            return this.qf(a, b);
        }
        qf(a, b) {
            if (b < a || a < 0 || a > this.qz.count || b < 0 || b > this.qz.count) {
                return null;
            }
            let c = new Array((b - a) + 1);
            for (let d = a; d <= b; d++) {
                let e = d;
                c[d - a] = this.ck.item(d);
            }
            return c;
        }
        static se(a, b, c) {
            let d = 0;
            let e = null;
            for (let f = 0; f < c.count; f++) {
                let g = c._inner[f];
                let h = g.b.width * g.b.height;
                if (h > d) {
                    d = h;
                    e = g;
                }
            }
            a.b9.addItem(b, e);
        }
        li() {
            super.li();
            if (this.qp != null) {
                this.qp.h6();
            }
            if (this.qr != null) {
                this.qr.h6();
            }
        }
        m9(a, b) {
            this.ml(false);
        }
        m8(a, b) {
            this.ml(false);
        }
        k3(a, b, c, d) {
            super.k3(a, b, c, d);
            switch (a) {
                case 3:
                    if (d == this.r1) {
                        this.rh._inner[b] = this.st(this.qz.item(b));
                    }
                    break;
                case 1:
                    for (let e = b; e < b + c; e++) {
                        this.rh.insert(e, this.st(this.qz.item(e)));
                    }
                    break;
                case 0:
                    this.rh.v(b, c);
                    break;
                case 2:
                    for (let f = b; f < b + c; f++) {
                        this.rh._inner[f] = this.st(this.qz.item(f));
                    }
                    break;
                case 4:
                    this.sg();
                    break;
            }
            this.ml(false);
        }
        fb(a, b, c) {
            let d = true;
            if (!super.fb(a, b, c) || (this.rb && this.qz == null) || b.isEmpty || a.isEmpty || this.qp == null || this.qr == null || this.qp.bh == null || this.qr.bh == null || this.qp.lv == this.qp.lu || this.qr.lv == this.qr.lu || this.qz == null || this.qz.count == 0 || this.rh == null || this.rh.count == 0 || this.rh.count != this.qz.count) {
                d = false;
            }
            return d;
        }
        get_rb() {
            return true;
        }
        get rb() {
            return this.get_rb();
        }
        l2(a) {
            super.l2(a);
            this.qx = typeCast(ShapeSeriesViewBase.$, a);
        }
        rk(a, b, c, d, e, f, g) {
            let h = new List$1(FlattenedShape.$, 0);
            let i;
            let j = c.count;
            for (let k = 0; k < j; k++) {
                i = c._inner[k];
                let l = this.qi(a, b, i, d, e, f, g);
                if (l == null) {
                    continue;
                }
                h.add(l);
            }
            return h;
        }
        qi(a, b, c, d, e, f, g) {
            let h = this.r8(c, d, e);
            let i = h.c;
            let j = h.d;
            let k = i.length;
            let l = 1.7976931348623157E+308;
            let m = 1.7976931348623157E+308;
            let n = -1.7976931348623157E+308;
            let o = -1.7976931348623157E+308;
            let p;
            let q;
            if (f != 0) {
                for (let r = 0; r < k; r++) {
                    i[r] = i[r] + f;
                }
            }
            for (let s = 0; s < k; s++) {
                p = i[s];
                q = j[s];
                l = p < l ? p : l;
                m = q < m ? q : m;
                n = p > n ? p : n;
                o = q > o ? q : o;
            }
            let t = !(l > this.ss.right || n < this.ss.left || m > this.ss.bottom || o < this.ss.top);
            if (!t && f == 0 && g != 0) {
                if (g != 0) {
                    for (let u = 0; u < k; u++) {
                        i[u] = i[u] + g;
                    }
                }
                for (let v = 0; v < k; v++) {
                    p = i[v];
                    q = j[v];
                    l = p < l ? p : l;
                    m = q < m ? q : m;
                    n = p > n ? p : n;
                    o = q > o ? q : o;
                }
                t = !(l > this.ss.right || n < this.ss.left || m > this.ss.bottom || o < this.ss.top);
            }
            if (!t) {
                return null;
            }
            let w = b != null && (l < this.ss.left || m < this.ss.top || n > this.ss.right || o > this.ss.bottom);
            let x = new Rect(0, l, m, n - l, o - m);
            if (!a.b8(x)) {
                return null;
            }
            l = l < this.ss.left ? this.ss.left : l;
            n = n > this.ss.right ? this.ss.right : n;
            m = m < this.ss.top ? this.ss.top : m;
            o = o > this.ss.bottom ? this.ss.bottom : o;
            let y = PolySimplification.b(h, this.fv);
            let z = new DefaultFlattener().c(h.c, h.d, y, this.rl);
            let aa = z.count;
            if (w) {
                let ab = new List$1(Point_$type, 0);
                b.i = ab;
                for (let ac = 0; ac < aa; ac++) {
                    b.j(z._inner[ac]);
                }
                b.i = null;
                z = ab;
            }
            if (z == null || z.count == 0) {
                return null;
            }
            let ad = new FlattenedShape();
            ad.a = z;
            ad.b = new Rect(0, l, m, n - l, o - m);
            ad.c = x;
            return ad;
        }
        r8(a, b, c) {
            let d = this.qo;
            let e = this.qq;
            let f = a.count;
            let g = new Array(f);
            let h = new Array(f);
            for (let i = 0; i < f; i++) {
                g[i] = a._inner[i].x;
                h[i] = a._inner[i].y;
            }
            d.hm(boxArray$1(g), 0, g.length, b);
            e.hm(boxArray$1(h), 0, h.length, c);
            return new Tuple$2(Array_$type, Array_$type, g, h);
        }
        si(a) {
            a.cx();
        }
        k0(a, b) {
            super.k0(a, b);
            let c = b;
            c.ck();
        }
        r9(a) {
            if (a != null) {
                a.cs(this);
            }
        }
        sh(a) {
            if (a != null) {
                a.bz(this);
            }
        }
        at(a, b) {
            let c = this.qx.cz(a, b);
            let d = null;
            if (c != null) {
                d = c.dataContext;
            }
            if (d != null) {
                return d;
            }
            return super.at(a, b);
        }
        rs(a) {
            return this.ck.item(a);
        }
        get_e5() {
            return true;
        }
        set_e5(a) {
            super.set_e5(a);
        }
        ap(a) {
            if (typeCast(NumericXAxis.$, a) !== null && this.rh != null) {
                let b = 1.7976931348623157E+308;
                let c = -1.7976931348623157E+308;
                for (let d of fromEnum(this.rh)) {
                    b = Math.min(b, d.left);
                    c = Math.max(c, d.right);
                }
                return new AxisRange(b, c);
            }
            if (typeCast(NumericYAxis.$, a) !== null && this.rh != null) {
                let e = 1.7976931348623157E+308;
                let f = -1.7976931348623157E+308;
                for (let g of fromEnum(this.rh)) {
                    e = Math.min(e, g.top);
                    f = Math.max(f, g.bottom);
                }
                return new AxisRange(e, f);
            }
            return null;
        }
        get_ee() {
            return true;
        }
        get_d3() {
            return true;
        }
        get q5() {
            return this.styleShape != null;
        }
        su(a, b, c) {
            if (this.styleShape != null) {
                if (this.qx.c6 != null && c == this.qx.c6) {
                    c = new Style();
                    let d = this.qx.c6;
                    c.fill = d.fill;
                    c.opacity = d.opacity;
                    c.stroke = d.stroke;
                    c.strokeThickness = d.strokeThickness;
                }
                else {
                    if (c != null) {
                        let e = new Style();
                        e.fill = c.fill;
                        e.opacity = c.opacity;
                        e.stroke = c.stroke;
                        e.strokeThickness = c.strokeThickness;
                        c = e;
                    }
                    else {
                        c = new Style();
                    }
                }
                let f = new StyleShapeEventArgs(a, b, c);
                this.styleShape(this, f);
                return f.d();
            }
            return c;
        }
    }
    ShapeSeriesBase.$t = markType(ShapeSeriesBase, 'ShapeSeriesBase', Series.$);
    ShapeSeriesBase.$$p = markDep(DependencyProperty, PropertyMetadata, ShapeSeriesBase, 'raisePropertyChanged', ['IsCustomShapeMarkerStyleAllowed:q8:sj', [0, false], 'IsCustomShapeStyleAllowed:q9:sk', [0, false], 'ItemSearchMode:qv:sl', [ShapeItemSearchMode_$type, enumGetBox(ShapeItemSearchMode_$type, 0)], 'ItemSearchPointsThreshold:rq:sm', [1, 10000], 'ItemSearchThreshold:rr:sn', [1, 10000], 'ShapeFilterResolution:rn:so', [1, 2], 'ShapeMemberPath:r1:sp', [2, null], 'XAxis:qp:sq', [NumericXAxis.$, null], 'YAxis:qr:sr', [NumericYAxis.$, null]]);
    return ShapeSeriesBase;
})();
/**
 * @hidden
 */
export let ShapeSeriesRenderManager = /*@__PURE__*/ (() => {
    class ShapeSeriesRenderManager extends SeriesRenderManager {
        constructor() {
            super(...arguments);
            this.au = null;
            this.av = null;
        }
        c() {
            this.au = new AssigningShapeMarkerStyleEventArgs();
            return this.au;
        }
        a() {
            this.av = new AssigningShapeStyleEventArgs();
            return this.av;
        }
        az(a, b, c) {
            this.ag = this.ak;
            this.ah = this.al;
            this.m = this.t;
            this.am = this.an;
            this.ao = this.ar;
            this.k = this.r;
            this.l = this.s;
            this.j = this.q;
            if (c) {
                if (a._fill != null) {
                    this.ag = a._fill;
                }
                if (a._stroke != null) {
                    this.ah = a._stroke;
                }
                if (!isNaN_(a.ac) && (a.y == null || !isNaN_(a.y.strokeThickness))) {
                    this.m = a.ac;
                }
            }
            let d = this.b;
            if (d != null) {
                d.p = this.ag;
                d.q = this.ah;
                d.t = this.m;
                d.u = this.am;
                d.v = this.ao;
                d.r = this.k;
                d.s = this.l;
                d.k = this.j;
                d.e = this.f;
                d.i = b;
                d.d = false;
            }
        }
        aw(a, b, c) {
            this.w(a, b, c);
        }
        ax(a, b, c) {
            this.x(a, b, c);
        }
        ay(a, b, c, d) {
            if (b == -1) {
                a.c = false;
                a.o = 0;
                a.n = c - 1;
            }
            else {
                if (d) {
                    a.o = b;
                    a.n = b;
                }
                else {
                    a.c = false;
                    a.o = b;
                    a.n = b;
                }
            }
        }
    }
    ShapeSeriesRenderManager.$t = markType(ShapeSeriesRenderManager, 'ShapeSeriesRenderManager', SeriesRenderManager.$);
    return ShapeSeriesRenderManager;
})();
/**
 * @hidden
 */
export let ShapeSeriesViewBase = /*@__PURE__*/ (() => {
    class ShapeSeriesViewBase extends SeriesView {
        constructor(a) {
            super(a);
            this.b9 = null;
            this.b3 = null;
            this.ca = new List$1(ShapeHitRegion.$, 0);
            this.ce = 0;
            this.cd = null;
            this.b6 = null;
            this.c4 = new Path();
            this.b4 = null;
            this.c5 = null;
            this.by = null;
            this.b0 = null;
            this.bz = null;
            this.bx = null;
            this.b3 = a;
            this.b6 = this.b5();
            this.cd = new List$1(Path.$, 0);
            this.b9 = new Dictionary$2(Number_$type, FlattenedShape.$, 0);
        }
        b1(a) {
            return null;
        }
        get cb() {
            return this.ca;
        }
        b5() {
            return ((() => {
                let $ret = new Pool$1(FrameworkElement.$);
                $ret.create = runOn(this, this.cy);
                $ret.activate = runOn(this, this.cn);
                $ret.disactivate = runOn(this, this.co);
                $ret.destroy = runOn(this, this.cp);
                return $ret;
            })());
        }
        b8(a) {
            return a.width >= this.b3.ro && a.height >= this.b3.ro;
        }
        static cc(a) {
            let b = new List$1(PointCollection.$, 0);
            let c;
            let d = a.count;
            for (let e = 0; e < d; e++) {
                c = a._inner[e];
                let f = new PointCollection(1, c.a);
                b.add(f);
            }
            return b;
        }
        get b7() {
            return this.c5 != null || this.b4 != null || this.b3.q5;
        }
        cf(a, b, c, d) {
            if (d != null && d.count > 0) {
                let e = ShapeSeriesViewBase.cc(d);
                c.intersect(this.bu);
                if (!this.b8(c)) {
                }
                else {
                    let f = this.c2(a, e);
                    if (f != null) {
                        let g = this.c1(this.ce, b);
                        for (let h = 0; h < d.count; h++) {
                            let i = new ShapeHitRegion();
                            i.d = d._inner[h].b;
                            i.a = d._inner[h].a;
                            i.b = a;
                            i.c = g;
                            this.ca.add(i);
                        }
                        this.ch(g, f);
                        this.ce = this.ce + 1;
                    }
                }
            }
        }
        c1(a, b) {
            let c = this.b6.item(this.ce);
            if (c.dataContext != null) {
                c.dataContext.item = b;
                c.dataContext.c = a;
            }
            return c;
        }
        static ci(a, b, c) {
            if (b._fill == null) {
                b._fill = a.e.o3;
            }
            if (b._stroke == null) {
                b._stroke = a.e.o6;
            }
            if (b.y == null) {
                b.ac = a.e.fw;
            }
        }
        cm(a) {
            for (let b = 0; b < this.b6.a.count; b++) {
                let c = this.b6.a._inner[b];
                a(c);
            }
        }
        cj(a, b, c) {
            if (a == null) {
                return;
            }
            this.cl(a, c);
            let d = false;
            if (this.b4 != null) {
                let e = this.b4.selectStyle(b, a);
                if (e != null) {
                    d = true;
                }
                if (a.y != e) {
                    a.y = e;
                    this.k.j(a, a.y);
                }
            }
            if (!d) {
                if (a.y != this.c5) {
                    a.y = this.c5;
                    this.k.j(a, a.y);
                }
            }
            let f = this.b3.su(b, a, a.y);
            if (a.y != f) {
                a.y = f;
                this.k.j(a, a.y);
            }
        }
        cl(a, b) {
        }
        cg(a, b) {
            let c = truncate(Math.floor(a.left));
            let d = truncate(Math.ceil(a.right));
            let e = truncate(Math.floor(a.top));
            let f = truncate(Math.ceil(a.bottom));
            for (let g = c; g < d; g++) {
                for (let h = e; h < f; h++) {
                    this.cu(g, h, b);
                }
            }
        }
        cu(a, b, c) {
        }
        cr() {
            this.ce = 0;
        }
        cq() {
            this.b6.count = this.ce;
            this.aq();
        }
        ct(a, b) {
        }
        ck() {
            this.b6.count = 0;
            this.aq();
        }
        cy() {
            let a = this.b3;
            let b = ((() => {
                let $ret = new Path();
                $ret.dataContext = ((() => {
                    let $ret = new DataContext();
                    $ret.series = a;
                    return $ret;
                })());
                return $ret;
            })());
            this.cd.add(b);
            return b;
        }
        cn(a) {
            a._visibility = 0;
        }
        co(a) {
            a.dataContext.item = null;
            a._visibility = 1;
        }
        cp(a) {
            this.cd.remove(a);
        }
        c3(a, b, c) {
            if (b == null) {
                return null;
            }
            let d = new PathGeometry();
            let e;
            let f = b.count;
            for (let g = 0; g < f; g++) {
                e = b._inner[g];
                if (e.count < 1) {
                    continue;
                }
                let h = new PolyLineSegment();
                h._points = e;
                let i = new PathFigure();
                i._isFilled = c;
                i._isClosed = c;
                i._startPoint = e._inner[0];
                i._segments.add(h);
                d.c.add(i);
            }
            return d;
        }
        ac(a) {
            return this.cd._inner[a];
        }
        ab(a) {
            let b = this.cd._inner[a];
            this.c4._visibility = b._visibility;
            this.c4.ak = b.ak;
            let c = this.bp(a);
            this.c4._fill = c;
            this.c4._stroke = c;
            this.c4.ac = this.e.fw + 3;
            return this.c4;
        }
        a6(a, b) {
            super.a6(a, b);
            for (let c = 0; c < this.cd.count; c++) {
                let d = this.aa(c, b);
                if (d._visibility != 1) {
                    a.t(d);
                }
            }
        }
        get c6() {
            return this.c5;
        }
        cw(a) {
            this.b4 = a;
        }
        cv(a) {
            this.c5 = a;
        }
        cz(a, b) {
            return this.c0(a, b, false);
        }
        c0(a, b, c) {
            let d = this.b2(a, b, c);
            if (d == null) {
                return null;
            }
            return d.c;
        }
        b2(a, b, c) {
            if (this.ca.count == 0) {
                return null;
            }
            let d = a.x;
            let e = a.y;
            let f = this.ca.count;
            let g = this.ca;
            let h = null;
            for (let i = 0; i < f; i++) {
                h = g._inner[i];
                if (h.a == null || h.a.count == 0) {
                    continue;
                }
                if (d >= h.d.left && d <= h.d.right && e >= h.d.top && e <= h.d.bottom) {
                    if (c) {
                        let j = this.b3.fw / 2 + this.b3.ga(b);
                        if (GeometryUtil.b(a, h.a._inner[0], h.a, j)) {
                            return h;
                        }
                    }
                    else {
                        if (PolygonUtil.b(h.a, a)) {
                            return h;
                        }
                    }
                }
            }
            return null;
        }
        cs(a, b, c, d) {
            this.by = a;
            this.b0 = b;
            this.bz = c;
            this.bx = d;
            this.ca.clear();
        }
        cx() {
            let a = this.bu;
            let b = ((() => {
                let $ret = new Path();
                $ret.y = this.c5;
                return $ret;
            })());
            b.ac = 1;
            if (this.k != null) {
                this.k.j(b, b.y);
            }
            this.b3.ss = RectUtil.r(a, b.ac);
        }
        al(a) {
            super.al(a);
            if (this.b6.a == null) {
                return;
            }
            for (let b = 0; b < this.b6.a.count; b++) {
                let c = typeCast(Path.$, this.b6.a._inner[b]);
                if (c._visibility != 1) {
                    this.e.a8.exportPathData(a, c, "shape" + b, ["Main "]);
                }
            }
        }
    }
    ShapeSeriesViewBase.$t = markType(ShapeSeriesViewBase, 'ShapeSeriesViewBase', SeriesView.$);
    return ShapeSeriesViewBase;
})();
