/*
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 * as tslib_1 from "tslib";
import { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { IEnumerable$1_$type, Type, typeCast, Point_$type, fromEnum, Array_$type, Number_$type, markType, runOn } from "igniteui-react-core/ES5/type";
import { NumericXAxis } from "./NumericXAxis";
import { NumericYAxis } from "./NumericYAxis";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { IFastItemsSource_$type } from "igniteui-react-core/ES5/IFastItemsSource";
import { PointCollectionUtil } from "igniteui-react-core/ES5/PointCollectionUtil";
import { FlattenedShape } from "./FlattenedShape";
import { SeriesView } from "./SeriesView";
import { Clipper } from "igniteui-react-core/ES5/Clipper";
import { ScalerParams } from "./ScalerParams";
import { Dictionary$2 } from "igniteui-react-core/ES5/Dictionary$2";
import { Tuple$2 } from "igniteui-react-core/ES5/Tuple$2";
import { PolySimplification } from "igniteui-react-core/ES5/PolySimplification";
import { DefaultFlattener } from "./DefaultFlattener";
import { DataContext } from "igniteui-react-core/ES5/DataContext";
import { FrameworkElement } from "igniteui-react-core/ES5/FrameworkElement";
import { AxisRange } from "./AxisRange";
import { StyleShapeEventArgs } from "./StyleShapeEventArgs";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { boxArray$1 } from "igniteui-react-core/ES5/array";
import { InvalidOperationException } from "igniteui-react-core/ES5/InvalidOperationException";
import { FastItemObjectColumn } from "igniteui-react-core/ES5/FastItemObjectColumn";
import { Path } from "igniteui-react-core/ES5/Path";
import { Pool$1 } from "igniteui-react-core/ES5/Pool$1";
import { ShapeHitRegion } from "./ShapeHitRegion";
import { PointCollection } from "igniteui-react-core/ES5/PointCollection";
import { PathGeometry } from "igniteui-react-core/ES5/PathGeometry";
import { PolyLineSegment } from "igniteui-react-core/ES5/PolyLineSegment";
import { PathFigure } from "igniteui-react-core/ES5/PathFigure";
import { GeometryUtil } from "igniteui-react-core/ES5/GeometryUtil";
import { PolygonUtil } from "igniteui-react-core/ES5/PolygonUtil";
import { RectUtil } from "igniteui-react-core/ES5/RectUtil";
import { truncate } from "igniteui-react-core/ES5/number";
/**
 * @hidden
 */
var ShapeSeriesBase = /** @class */ (function (_super) {
    tslib_1.__extends(ShapeSeriesBase, _super);
    function ShapeSeriesBase() {
        var _this = _super.call(this) || this;
        _this.l3 = null;
        _this.ly = null;
        _this.l0 = null;
        _this.mf = 0;
        _this.mb = null;
        _this.lu = null;
        _this.lw = null;
        _this.lv = null;
        _this.lt = null;
        _this.m0 = null;
        _this.mh = 0;
        _this.styleShape = null;
        FastItemObjectColumn.k();
        _this.mh = _this.mg;
        _this.m0 = Rect.empty;
        return _this;
    }
    ShapeSeriesBase.prototype.hn = function () {
        _super.prototype.hn.call(this);
        this.lz = null;
        this.l1 = null;
    };
    ShapeSeriesBase.prototype.ag = function () {
        return [this.lz, this.l1];
    };
    Object.defineProperty(ShapeSeriesBase.prototype, "l4", {
        get: function () {
            return this.l3;
        },
        set: function (a) {
            var b = this.l4 != a;
            if (b) {
                var c = this.l4;
                this.l3 = a;
                this.raisePropertyChanged("ShapeColumn", c, this.l4);
            }
        },
        enumerable: true,
        configurable: true
    });
    ShapeSeriesBase.prototype.l7 = function (array_) {
        var a = (Array.isArray(array_));
        return a;
    };
    ShapeSeriesBase.prototype.convertToListList = function (a) {
        if (a == null) {
            return null;
        }
        var b = new List$1(List$1.$.specialize(Point_$type), 0);
        var c;
        var curr_;
        var d;
        var e;
        for (var f = 0; f < a.length; f++) {
            c = a[f];
            var g = new List$1(Point_$type, 0);
            for (var h = 0; h < c.length; h++) {
                curr_ = c[h];
                d = (curr_.x);
                e = (curr_.y);
                g.add({ $type: Point_$type, x: d, y: e });
            }
            b.add(g);
        }
        return b;
    };
    ShapeSeriesBase.prototype.by = function (a) {
        if (this.bz != null && this.l7(this.itemsSource) && a != null && a.split('!').length != 2) {
            if (this.coercionMethods == null) {
                this.coercionMethods = {};
            }
            var methods_ = this.coercionMethods;
            methods_.convertToListList = this.convertToListList;
            a += "!convertToListList";
        }
        return _super.prototype.by.call(this, a);
    };
    ShapeSeriesBase.prototype.is = function (a, b, c, d) {
        _super.prototype.is.call(this, a, b, c, d);
        var e = false;
        var f = false;
        switch (b) {
            case "FastItemsSource":
                var g = typeCast(IFastItemsSource_$type, c);
                if (g != null) {
                    g.deregisterColumn(this.l4);
                    this.l4 = null;
                }
                var h = typeCast(IFastItemsSource_$type, d);
                if (h != null) {
                    this.l4 = this.by(this.mm);
                }
                e = this.lz != null && !this.lz.ck();
                f = this.l1 != null && !this.l1.ck();
                if (e || f) {
                    this.i6(false);
                }
                break;
            case ShapeSeriesBase.$$p[1]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.l4);
                    this.l4 = this.by(this.mm);
                }
                break;
            case "ShapeColumn":
                this.mt();
                e = this.lz != null && !this.lz.ck();
                f = this.l1 != null && !this.l1.ck();
                if (e || f) {
                    this.i6(false);
                }
                this.ic();
                break;
            case ShapeSeriesBase.$$p[2]:
            case ShapeSeriesBase.$$p[3]:
                this.ly = this.lz;
                this.l0 = this.l1;
                var i = c;
                var j = d;
                this.mu(i);
                this.mr(j);
                if ((j != null && !j.ck()) || (j == null && i != null)) {
                    this.i6(false);
                }
                this.ic();
                break;
            case "Resolution":
                this.mf = this.er;
                this.ic();
                break;
            case "ActualBrush":
                this.i6(false);
                break;
            case ShapeSeriesBase.$$p[0]:
                this.mh = this.mg;
                this.i6(false);
                this.ic();
                break;
            case "Thickness":
                this.i6(false);
                this.ic();
                break;
        }
    };
    ShapeSeriesBase.prototype.l6 = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ShapeSeriesBase.prototype.l5 = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ShapeSeriesBase.prototype.mt = function () {
        this.mb = null;
        if (this.l4 == null) {
            return;
        }
        this.mb = new List$1(Rect.$, 2, this.l4.count);
        for (var a = 0; a < this.l4.count; a++) {
            this.mb.add(PointCollectionUtil.j(this.l4.item(a)));
        }
    };
    ShapeSeriesBase.prototype.m1 = function (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;
    };
    ShapeSeriesBase.prototype.md = function (a, b, c, d, e) {
        var e_1, _a;
        return this.me(a, b, c, d, e);
        if (typeCast(List$1.$.specialize(List$1.$.specialize(Point_$type)), c) !== null) {
            return this.me(a, b, c, d, e);
        }
        else if (typeCast(IEnumerable$1_$type.specialize(IEnumerable$1_$type.specialize(Point_$type)), c) !== null) {
            var f = c;
            var g = new List$1(FlattenedShape.$, 0);
            var h = null;
            try {
                for (var _b = tslib_1.__values(fromEnum(f)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var i = _c.value;
                    h = this.lx(a, b, PointCollectionUtil.b(i), d, e);
                    if (h == null) {
                        continue;
                    }
                    g.add(h);
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_1) throw e_1.error; }
            }
            return g;
        }
        else if (typeCast(IEnumerable$1_$type.specialize(Point_$type), c) !== null) {
            var j = c;
            var k = this.lx(a, b, PointCollectionUtil.b(j), d, e);
            var l = new List$1(FlattenedShape.$, 0);
            if (k != null) {
                l.add(k);
            }
            return l;
        }
        else {
            throw new InvalidOperationException(1, "Unrecognized data in ShapeColumn");
        }
    };
    ShapeSeriesBase.prototype.get_l8 = function () {
        return true;
    };
    Object.defineProperty(ShapeSeriesBase.prototype, "l8", {
        get: function () {
            return this.get_l8();
        },
        enumerable: true,
        configurable: true
    });
    ShapeSeriesBase.prototype.ma = function () {
        return false;
    };
    ShapeSeriesBase.prototype.i7 = function (a) {
        this.ms(this.bi);
    };
    ShapeSeriesBase.prototype.i5 = function (a, b, c, d, e) {
        _super.prototype.i5.call(this, a, b, c, d, e);
        var f = this.a0.a$h.item(d);
        var g = f;
        f.ay(c);
        if (this.cc(f)) {
            return;
        }
        this.ms(f);
    };
    ShapeSeriesBase.prototype.ms = function (a) {
        if (this.cc(a)) {
            return;
        }
        var b;
        var c;
        var d = a;
        var e = a.getViewInfo(c, b);
        c = e.p0;
        b = e.p1;
        if (c.width < 1 || c.height < 1 || this.l4 == null) {
            return;
        }
        var f = this.lz;
        var g = this.l1;
        var h = this.getEffectiveViewport1(a);
        var i = new ScalerParams(1, b, c, f.b8);
        i.c = h;
        var j = new ScalerParams(1, b, c, g.b8);
        j.c = h;
        d.cj();
        var k = new Rect(0, 0, 0, 0, 0);
        var l;
        var m;
        var n;
        var o;
        var p = this.l4.count;
        if (this.lw == null || this.lw.length != p) {
            this.lw = new Array(p);
            this.lu = new Array(p);
            this.lv = new Array(p);
            this.lt = new Array(p);
        }
        var q = this.lw;
        var r = this.lu;
        var s = this.lv;
        var t = this.lt;
        var u;
        for (var v = 0; v < p; v++) {
            u = this.mb._inner[v];
            q[v] = u.top;
            r[v] = u.left;
            s[v] = u.right;
            t[v] = u.bottom;
        }
        this.ly.gh(boxArray$1(r), 0, r.length, i);
        this.ly.gh(boxArray$1(s), 0, s.length, i);
        this.l0.gh(boxArray$1(q), 0, q.length, j);
        this.l0.gh(boxArray$1(t), 0, t.length, j);
        d.ck(r, q, s, t);
        var w = this.l4;
        var x = this.bz;
        this.mv(d);
        var y = c.left;
        var z = c.right;
        var aa = c.top;
        var ab = c.bottom;
        var ac = null;
        if (this.m0.isEmpty) {
            ac = null;
        }
        else {
            ac = new Clipper(1, this.m0.left, this.m0.bottom, this.m0.right, this.m0.top, this.l8);
        }
        var ad = this.ma();
        if (ad) {
            d.b3.clear();
        }
        var ae;
        for (var af = 0; af < p; af++) {
            n = r[af];
            l = q[af];
            m = t[af];
            o = s[af];
            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) {
                    ae = ac;
                }
                else {
                    ae = null;
                }
                var ag = this.md(a, ae, w.item(af), i, j);
                if (ad) {
                    var ah = 0;
                    var ai = null;
                    for (var aj = 0; aj < ag.count; aj++) {
                        var ak = ag._inner[aj];
                        var al = ak.b.width * ak.b.height;
                        if (al > ah) {
                            ah = al;
                            ai = ak;
                        }
                    }
                    d.b3.addItem(af, ai);
                }
                d.b8(af, x.item(af), k, ag);
            }
        }
        d.ci();
    };
    ShapeSeriesBase.prototype.h4 = function () {
        _super.prototype.h4.call(this);
        if (this.lz != null) {
            this.lz.gz();
        }
        if (this.l1 != null) {
            this.l1.gz();
        }
    };
    ShapeSeriesBase.prototype.jm = function (a, b) {
        this.i6(false);
    };
    ShapeSeriesBase.prototype.jl = function (a, b) {
        this.i6(false);
    };
    ShapeSeriesBase.prototype.hs = function (a, b, c, d) {
        _super.prototype.hs.call(this, a, b, c, d);
        switch (a) {
            case 3:
                if (d == this.mm) {
                    this.mb._inner[b] = this.m1(this.l4.item(b));
                }
                break;
            case 1:
                for (var e = b; e < b + c; e++) {
                    this.mb.insert(e, this.m1(this.l4.item(e)));
                }
                break;
            case 0:
                this.mb.v(b, c);
                break;
            case 2:
                for (var f = b; f < b + c; f++) {
                    this.mb._inner[f] = this.m1(this.l4.item(f));
                }
                break;
            case 4:
                this.mt();
                break;
        }
        this.i6(false);
    };
    ShapeSeriesBase.prototype.dv = function (a, b, c) {
        var d = true;
        if (!_super.prototype.dv.call(this, a, b, c) || (this.l9 && this.l4 == null) || b.isEmpty || a.isEmpty || this.lz == null || this.l1 == null || this.lz.bf == null || this.l1.bf == null || this.lz.jx == this.lz.jw || this.l1.jx == this.l1.jw || this.l4 == null || this.l4.count == 0 || this.mb == null || this.mb.count == 0 || this.mb.count != this.l4.count) {
            d = false;
        }
        return d;
    };
    ShapeSeriesBase.prototype.get_l9 = function () {
        return true;
    };
    Object.defineProperty(ShapeSeriesBase.prototype, "l9", {
        get: function () {
            return this.get_l9();
        },
        enumerable: true,
        configurable: true
    });
    ShapeSeriesBase.prototype.im = function (a) {
        _super.prototype.im.call(this, a);
        this.l2 = typeCast(ShapeSeriesViewBase.$, a);
    };
    ShapeSeriesBase.prototype.me = function (a, b, c, d, e) {
        var f = new List$1(FlattenedShape.$, 0);
        var g;
        var h = c.count;
        for (var i = 0; i < h; i++) {
            g = c._inner[i];
            var j = this.lx(a, b, g, d, e);
            if (j == null) {
                continue;
            }
            f.add(j);
        }
        return f;
    };
    ShapeSeriesBase.prototype.lx = function (a, b, c, d, e) {
        var f = this.mq(c, d, e);
        var g = f.c;
        var h = f.d;
        var i = g.length;
        var j = 1.7976931348623157E+308;
        var k = 1.7976931348623157E+308;
        var l = -1.7976931348623157E+308;
        var m = -1.7976931348623157E+308;
        var n;
        var o;
        for (var p = 0; p < i; p++) {
            n = g[p];
            o = h[p];
            j = n < j ? n : j;
            k = o < k ? o : k;
            l = n > l ? n : l;
            m = o > m ? o : m;
        }
        var q = !(j > this.m0.right || l < this.m0.left || k > this.m0.bottom || m < this.m0.top);
        if (!q) {
            return null;
        }
        var r = b != null && (j < this.m0.left || k < this.m0.top || l > this.m0.right || m > this.m0.bottom);
        var s = new Rect(0, j, k, l - j, m - k);
        if (!a.b2(s)) {
            return null;
        }
        j = j < this.m0.left ? this.m0.left : j;
        l = l > this.m0.right ? this.m0.right : l;
        k = k < this.m0.top ? this.m0.top : k;
        m = m > this.m0.bottom ? this.m0.bottom : m;
        var t = PolySimplification.b(f, this.er);
        var u = new DefaultFlattener().c(f.c, f.d, t, this.mf);
        var v = u.count;
        if (r) {
            var w = new List$1(Point_$type, 0);
            b.i = w;
            for (var x = 0; x < v; x++) {
                b.j(u._inner[x]);
            }
            b.i = null;
            u = w;
        }
        if (u == null || u.count == 0) {
            return null;
        }
        var y = new FlattenedShape();
        y.a = u;
        y.b = new Rect(0, j, k, l - j, m - k);
        y.c = s;
        return y;
    };
    ShapeSeriesBase.prototype.mq = function (a, b, c) {
        var d = this.ly;
        var e = this.l0;
        var f = a.count;
        var g = new Array(f);
        var h = new Array(f);
        for (var i = 0; i < f; i++) {
            g[i] = a._inner[i].x;
            h[i] = a._inner[i].y;
        }
        d.gh(boxArray$1(g), 0, g.length, b);
        e.gh(boxArray$1(h), 0, h.length, c);
        return new Tuple$2(Array_$type, Array_$type, g, h);
    };
    ShapeSeriesBase.prototype.mv = function (a) {
        a.cp();
    };
    ShapeSeriesBase.prototype.hp = function (a, b) {
        _super.prototype.hp.call(this, a, b);
        var c = b;
        c.cd();
    };
    ShapeSeriesBase.prototype.mr = function (a) {
        if (a != null) {
            a.ch(this);
        }
    };
    ShapeSeriesBase.prototype.mu = function (a) {
        if (a != null) {
            a.bv(this);
        }
    };
    ShapeSeriesBase.prototype.ar = function (a, b) {
        var c = this.l2.cr(a, b);
        var d = null;
        if (c != null) {
            d = c.dataContext;
        }
        if (d != null) {
            return d;
        }
        return _super.prototype.ar.call(this, a, b);
    };
    ShapeSeriesBase.prototype.mj = function (a) {
        return this.bz.item(a);
    };
    ShapeSeriesBase.prototype.get_dp = function () {
        return true;
    };
    ShapeSeriesBase.prototype.set_dp = function (a) {
        _super.prototype.set_dp.call(this, a);
    };
    ShapeSeriesBase.prototype.an = function (a) {
        var e_2, _a, e_3, _b;
        if (typeCast(NumericXAxis.$, a) !== null && this.mb != null) {
            var b = 1.7976931348623157E+308;
            var c = -1.7976931348623157E+308;
            try {
                for (var _c = tslib_1.__values(fromEnum(this.mb)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var d = _d.value;
                    b = Math.min(b, d.left);
                    c = Math.max(c, d.right);
                }
            }
            catch (e_2_1) { e_2 = { error: e_2_1 }; }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
                }
                finally { if (e_2) throw e_2.error; }
            }
            return new AxisRange(b, c);
        }
        if (typeCast(NumericYAxis.$, a) !== null && this.mb != null) {
            var e = 1.7976931348623157E+308;
            var f = -1.7976931348623157E+308;
            try {
                for (var _e = tslib_1.__values(fromEnum(this.mb)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var g = _f.value;
                    e = Math.min(e, g.top);
                    f = Math.max(f, g.bottom);
                }
            }
            catch (e_3_1) { e_3 = { error: e_3_1 }; }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
                }
                finally { if (e_3) throw e_3.error; }
            }
            return new AxisRange(e, f);
        }
        return null;
    };
    ShapeSeriesBase.prototype.get_c5 = function () {
        return true;
    };
    ShapeSeriesBase.prototype.m2 = function (a, b, c) {
        if (this.styleShape != null) {
            var d = new StyleShapeEventArgs(a, b, c);
            this.styleShape(this, d);
            return d.d();
        }
        return null;
    };
    ShapeSeriesBase.$t = markType(ShapeSeriesBase, 'ShapeSeriesBase', Series.$);
    return ShapeSeriesBase;
}(Series));
export { ShapeSeriesBase };
Type.dep(DependencyProperty, PropertyMetadata, ShapeSeriesBase, 'raisePropertyChanged', ['ShapeFilterResolution:mg:mw', [1, 2], 'ShapeMemberPath:mm:mx', [2, null], 'XAxis:lz:my', [NumericXAxis.$, null], 'YAxis:l1:mz', [NumericYAxis.$, null]]);
/**
 * @hidden
 */
var ShapeSeriesViewBase = /** @class */ (function (_super) {
    tslib_1.__extends(ShapeSeriesViewBase, _super);
    function ShapeSeriesViewBase(a) {
        var _this = _super.call(this, a) || this;
        _this.b3 = null;
        _this.by = null;
        _this.b4 = new List$1(ShapeHitRegion.$, 0);
        _this.b7 = 0;
        _this.b6 = null;
        _this.b1 = null;
        _this.bz = null;
        _this.cw = null;
        _this.bv = null;
        _this.bx = null;
        _this.bw = null;
        _this.bu = null;
        _this.by = a;
        _this.b1 = _this.b0();
        _this.b6 = new List$1(Path.$, 0);
        _this.b3 = new Dictionary$2(Number_$type, FlattenedShape.$, 0);
        return _this;
    }
    ShapeSeriesViewBase.prototype.b0 = function () {
        var _this = this;
        return ((function () {
            var $ret = new Pool$1(FrameworkElement.$);
            $ret.create = runOn(_this, _this.cq);
            $ret.activate = runOn(_this, _this.cf);
            $ret.disactivate = runOn(_this, _this.cg);
            $ret.destroy = runOn(_this, _this.ch);
            return $ret;
        })());
    };
    ShapeSeriesViewBase.prototype.b2 = function (a) {
        return a.width >= this.by.mh && a.height >= this.by.mh;
    };
    ShapeSeriesViewBase.b5 = function (a) {
        var b = new List$1(PointCollection.$, 0);
        var c;
        var d = a.count;
        for (var e = 0; e < d; e++) {
            c = a._inner[e];
            var f = new PointCollection(1, c.a);
            b.add(f);
        }
        return b;
    };
    ShapeSeriesViewBase.prototype.b8 = function (a, b, c, d) {
        if (d != null && d.count > 0) {
            var e = ShapeSeriesViewBase.b5(d);
            c.intersect(this.br);
            if (!this.b2(c)) {
            }
            else {
                var f = this.cu(a, e);
                if (f != null) {
                    var g = this.ct(this.b7, b);
                    for (var h = 0; h < d.count; h++) {
                        var i = new ShapeHitRegion();
                        i.d = d._inner[h].b;
                        i.a = d._inner[h].a;
                        i.b = a;
                        i.c = g;
                        this.b4.add(i);
                    }
                    this.ce(g);
                    this.ca(g, f);
                    this.cc(g, b);
                    this.b7 = this.b7 + 1;
                }
            }
        }
    };
    ShapeSeriesViewBase.prototype.ct = function (a, b) {
        var c = this.b1.item(this.b7);
        if (c.dataContext != null) {
            c.dataContext.item = b;
        }
        return c;
    };
    ShapeSeriesViewBase.cb = function (a, b, c) {
        if (b._fill == null) {
            b._fill = a.e.kw;
        }
        if (b._stroke == null) {
            b._stroke = a.e.kx;
        }
        if (b.y == null) {
            b.ac = a.e.ev;
        }
    };
    ShapeSeriesViewBase.prototype.cc = function (a, b) {
        if (a == null) {
            return;
        }
        if (this.bz != null) {
            a.y = this.bz.selectStyle(b, a);
        }
        a.y = this.by.m2(b, a, a.y);
        if (a.y == null) {
            a.y = this.cw;
        }
    };
    ShapeSeriesViewBase.prototype.ce = function (a) {
    };
    ShapeSeriesViewBase.prototype.b9 = function (a, b) {
        var c = truncate(Math.floor(a.left));
        var d = truncate(Math.ceil(a.right));
        var e = truncate(Math.floor(a.top));
        var f = truncate(Math.ceil(a.bottom));
        for (var g = c; g < d; g++) {
            for (var h = e; h < f; h++) {
                this.cm(g, h, b);
            }
        }
    };
    ShapeSeriesViewBase.prototype.cm = function (a, b, c) {
    };
    ShapeSeriesViewBase.prototype.cj = function () {
        this.b7 = 0;
    };
    ShapeSeriesViewBase.prototype.ci = function () {
        this.b1.count = this.b7;
        this.an();
    };
    ShapeSeriesViewBase.prototype.cl = function (a, b) {
    };
    ShapeSeriesViewBase.prototype.cd = function () {
        this.b1.count = 0;
        this.an();
    };
    ShapeSeriesViewBase.prototype.cq = function () {
        var a = this.by;
        var b = ((function () {
            var $ret = new Path();
            $ret.dataContext = ((function () {
                var $ret = new DataContext();
                $ret.series = a;
                return $ret;
            })());
            return $ret;
        })());
        this.b6.add(b);
        return b;
    };
    ShapeSeriesViewBase.prototype.cf = function (a) {
        a._visibility = 0;
    };
    ShapeSeriesViewBase.prototype.cg = function (a) {
        a.dataContext.item = null;
        a._visibility = 1;
    };
    ShapeSeriesViewBase.prototype.ch = function (a) {
        this.b6.remove(a);
    };
    ShapeSeriesViewBase.prototype.cv = function (a, b, c) {
        if (b == null) {
            return null;
        }
        var d = new PathGeometry();
        var e;
        var f = b.count;
        for (var g = 0; g < f; g++) {
            e = b._inner[g];
            if (e.count < 1) {
                continue;
            }
            var h = new PolyLineSegment();
            h._points = e;
            var i = new PathFigure();
            i._isFilled = c;
            i._isClosed = c;
            i._startPoint = e._inner[0];
            i._segments.add(h);
            d.b.add(i);
        }
        return d;
    };
    ShapeSeriesViewBase.prototype.bb = function (a, b) {
        _super.prototype.bb.call(this, a, b);
        var c = a;
        c._fill = this.e.kw;
        c._stroke = this.e.kx;
        c.ac = this.e.ev;
        if (c.y != null) {
            this.h.i(c, c.y);
        }
    };
    ShapeSeriesViewBase.prototype.bc = function (a, b) {
        _super.prototype.bc.call(this, a, b);
        var c = a;
        var d = this.bm(b);
        c._fill = d;
        c._stroke = d;
        c.ac = this.e.ev + 3;
    };
    ShapeSeriesViewBase.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        for (var c = 0; c < this.b6.count; c++) {
            var d = this.b6._inner[c];
            if (d._visibility != 1) {
                this.ba(d, c, b);
                a.s(d);
            }
        }
    };
    ShapeSeriesViewBase.prototype.co = function (a) {
        this.bz = a;
    };
    ShapeSeriesViewBase.prototype.cn = function (a) {
        this.cw = a;
    };
    ShapeSeriesViewBase.prototype.cr = function (a, b) {
        return this.cs(a, b, false);
    };
    ShapeSeriesViewBase.prototype.cs = function (a, b, c) {
        if (this.b4.count == 0) {
            return null;
        }
        var d = a.x;
        var e = a.y;
        var f = this.b4.count;
        var g = this.b4;
        var h = null;
        for (var 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) {
                    var j = this.by.ev / 2 + this.by.eb(b);
                    if (GeometryUtil.b(a, h.a._inner[0], h.a, j)) {
                        return h.c;
                    }
                }
                else {
                    if (PolygonUtil.a(h.a, a)) {
                        return h.c;
                    }
                }
            }
        }
        return null;
    };
    ShapeSeriesViewBase.prototype.ck = function (a, b, c, d) {
        this.bv = a;
        this.bx = b;
        this.bw = c;
        this.bu = d;
        this.b4.clear();
    };
    ShapeSeriesViewBase.prototype.cp = function () {
        var _this = this;
        var a = this.br;
        var b = ((function () {
            var $ret = new Path();
            $ret.y = _this.cw;
            return $ret;
        })());
        b.ac = 1;
        if (this.h != null) {
            this.h.i(b, b.y);
        }
        this.by.m0 = RectUtil.r(a, b.ac);
    };
    ShapeSeriesViewBase.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        if (this.b1.a == null) {
            return;
        }
        for (var b = 0; b < this.b1.a.count; b++) {
            var c = typeCast(Path.$, this.b1.a._inner[b]);
            if (c._visibility != 1) {
                this.e.a2.exportPathData(a, c, "shape" + b, ["Main "]);
            }
        }
    };
    ShapeSeriesViewBase.$t = markType(ShapeSeriesViewBase, 'ShapeSeriesViewBase', SeriesView.$);
    return ShapeSeriesViewBase;
}(SeriesView));
export { ShapeSeriesViewBase };
