/*
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 { FinancialSeries } from "./FinancialSeries";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { TrendLineType_$type } from "igniteui-react-core/ES5/TrendLineType";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { Brush } from "igniteui-react-core/ES5/Brush";
import { PenLineCap_$type } from "igniteui-react-core/ES5/PenLineCap";
import { DoubleCollection } from "igniteui-react-core/ES5/DoubleCollection";
import { PriceDisplayType_$type } from "./PriceDisplayType";
import { Type, enumGetBox, EnumUtil, typeCast, fromEnum, runOn, Point_$type, markType } from "igniteui-react-core/ES5/type";
import { CategoryFrame } from "./CategoryFrame";
import { ISortingAxis_$type } from "./ISortingAxis";
import { FinancialSeriesView } from "./FinancialSeriesView";
import { Series } from "./Series";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { RectUtil } from "igniteui-react-core/ES5/RectUtil";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { AxisRange } from "./AxisRange";
import { ScalerParams } from "./ScalerParams";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { Pool$1 } from "igniteui-react-core/ES5/Pool$1";
import { Path } from "igniteui-react-core/ES5/Path";
import { PathGeometry } from "igniteui-react-core/ES5/PathGeometry";
import { PathFigure } from "igniteui-react-core/ES5/PathFigure";
import { LineSegment } from "igniteui-react-core/ES5/LineSegment";
import { GeometryGroup } from "igniteui-react-core/ES5/GeometryGroup";
import { LineGeometry } from "igniteui-react-core/ES5/LineGeometry";
import { RectangleGeometry } from "igniteui-react-core/ES5/RectangleGeometry";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { truncate, isNaN_ } from "igniteui-react-core/ES5/number";
import { boxArray$1 } from "igniteui-react-core/ES5/array";
import { FinancialPriceBucketCalculator } from "./FinancialPriceBucketCalculator";
import { Extensions } from "igniteui-react-core/ES5/Extensions";
/**
 * @hidden
 */
var FinancialPriceSeries = /** @class */ (function (_super) {
    tslib_1.__extends(FinancialPriceSeries, _super);
    function FinancialPriceSeries() {
        var _this = _super.call(this) || this;
        _this.ab = FinancialPriceSeries.$;
        _this.l4 = new CategoryFrame(5);
        _this.l6 = new CategoryFrame(5);
        _this.l3 = new CategoryFrame(5);
        return _this;
    }
    FinancialPriceSeries.prototype.bf = function () {
        return new FinancialPriceSeriesView(this);
    };
    FinancialPriceSeries.prototype.im = function (a) {
        _super.prototype.im.call(this, a);
        this.pc = a;
    };
    Object.defineProperty(FinancialPriceSeries.prototype, "pw", {
        get: function () {
            return this.c(FinancialPriceSeries.pm);
        },
        set: function (a) {
            this.h(FinancialPriceSeries.pm, a);
        },
        enumerable: true,
        configurable: true
    });
    FinancialPriceSeries.prototype.hs = function (a, b, c, d) {
        _super.prototype.hs.call(this, a, b, c, d);
        if (this.l1 != null && typeCast(ISortingAxis_$type, this.l1) !== null) {
            this.l1.i$i();
        }
        this.pc.bu.e(this.er);
        if (this.pc.b4) {
            this.pc.b2.g$e(a, b, c, d);
        }
        if (this.mm != null) {
            this.mm.ck();
        }
        this.i6(true);
    };
    FinancialPriceSeries.prototype.bd = function () {
        if (this.be == 0) {
            return 1;
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    FinancialPriceSeries.prototype.ln = function (a) {
        if (this.l3 == null || this.l3.f.count == 0) {
            return Rect.empty;
        }
        var b = this.k9(a);
        var c = this.bi.bs;
        var d = this.bi.br;
        var e = this.getEffectiveViewport1(this.bi);
        var f = this.aj(this.l1, this.l3.f, this.ny(this.bi), this.n0(this.bi), a, true);
        var g = f[0];
        var h = f[1];
        var i = Math.abs(b.x - g[0]);
        var j = Math.abs(b.x - h[0]);
        var k = this.pe(this.mh, e);
        k = Math.max(k, 3);
        var l = (k - 1) / 2;
        if (i < j) {
            var m = g[0] - l;
            var n = g[0];
            var o = g[0] + l;
            var p = g[1];
            var q = g[2];
            var r = g[3];
            var s = g[4];
            var t = Math.min(Math.min(Math.min(p, q), r), s);
            var u = Math.max(Math.max(Math.max(p, q), r), s);
            return new Rect(0, m, t, Math.abs(o - m), u - t);
        }
        else {
            var v = h[0] - l;
            var w = h[0];
            var x = h[0] + l;
            var y = h[1];
            var z = h[2];
            var aa = h[3];
            var ab = h[4];
            var ac = Math.min(Math.min(Math.min(y, z), aa), ab);
            var ad = Math.max(Math.max(Math.max(y, z), aa), ab);
            return new Rect(0, v, ac, Math.abs(x - v), ad - ac);
        }
    };
    FinancialPriceSeries.prototype.pb = function (a, b) {
        var c = a[0] - b;
        var d = a[0];
        var e = a[0] + b;
        var f = a[1];
        var g = a[2];
        var h = a[3];
        var i = a[4];
        var j = Math.min(Math.min(Math.min(f, g), h), i);
        var k = Math.max(Math.max(Math.max(f, g), h), i);
        var l = Math.min(g, h);
        var m = Math.max(g, h);
        var n = Math.min(f, i);
        var o = Math.max(f, i);
        if (this.pd == 1) {
            var p = new Array(3);
            var q = new Rect(0, c, f, b, 0);
            var r = new Rect(0, d, i, b, 0);
            var s = new Rect(0, d, l, 0, m - l);
            p[0] = q;
            p[1] = r;
            p[2] = s;
            return p;
        }
        else {
            var t = new Array(2);
            var u = new Rect(0, d, l, 0, m - l);
            var v = new Rect(0, c, n, b * 2, o - n);
            t[0] = u;
            t[1] = v;
            return t;
        }
    };
    FinancialPriceSeries.prototype.ak = function (a) {
        var b = new List$1(Rect.$, 0);
        var c = this.k9(a);
        var d = this.bi.bs;
        var e = this.bi.br;
        var f = this.getEffectiveViewport1(this.bi);
        var g = this.aj(this.l1, this.l3.f, this.ny(this.bi), this.n0(this.bi), a, true);
        var h = g[0];
        var i = g[1];
        var j = Math.abs(c.x - h[0]);
        var k = Math.abs(c.x - i[0]);
        var l = this.pe(this.mh, f);
        l = Math.max(l, 3);
        var m = (l - 1) / 2;
        if (j < k) {
            return this.pb(h, m);
        }
        else {
            return this.pb(i, m);
        }
    };
    FinancialPriceSeries.prototype.dg = function (a, b) {
        if (this.dj(a, b)) {
            return true;
        }
        return false;
    };
    FinancialPriceSeries.prototype.dj = function (a, b) {
        var c = this.lo(a);
        if (c.isEmpty) {
            return false;
        }
        var d = RectUtil.r(c, (this.ev / 2) + this.eb(b));
        if (d.containsPoint(a)) {
            var e = this.al(a);
            if (e != null) {
                for (var f = 0; f < e.length; f++) {
                    var g = e[f];
                    var h = RectUtil.r(g, (this.ev / 2) + this.eb(b));
                    if (h.containsPoint(a)) {
                        return true;
                    }
                }
            }
        }
        return false;
    };
    FinancialPriceSeries.prototype.is = function (a, b, c, d) {
        switch (b) {
            case FinancialSeries.$$p[9]:
                this.pc.ca();
                break;
            case "TrendLineType":
                var e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                if (e != 0) {
                    this.pc.b2 = CategoryTrendLineManagerFactory.a(this.pc.b2, this.l1, this.jq, this, this.b2);
                }
                break;
        }
        _super.prototype.is.call(this, a, b, c, d);
        if (this.pc.b4 && this.pc.b2 != null && this.pc.b2.g$b(a, b, c, d)) {
            this.i6(false);
            this.ic();
        }
        switch (b) {
            case FinancialPriceSeries.$$p[0]:
                if (this.jq != null) {
                    this.pl();
                    this.l3.w();
                    this.ou(this.l3, this.pc);
                }
                this.ic();
                break;
            case "TrendLineBrush":
                this.jh();
                break;
            case "TrendLineType":
                this.ic();
                break;
            case FinancialSeries.$$p[5]:
            case FinancialPriceSeries.$$p[1]:
                this.ip();
                break;
        }
    };
    FinancialPriceSeries.prototype.pl = function () {
        this.pc.ce();
        if (this.bh != null) {
            this.bh.ce();
        }
    };
    FinancialPriceSeries.prototype.an = function (a) {
        if (a != null && a == this.mm && this.mt != null && !isNaN_(this.mt.minimum) && this.mr != null && !isNaN_(this.mr.maximum)) {
            return new AxisRange(this.mt.minimum, this.mr.maximum);
        }
        return null;
    };
    FinancialPriceSeries.prototype.ao = function () {
        if (this.mt == null || this.mr == null) {
            return null;
        }
        var a = new ScalerParams(0, this.bs.mq, this.bs.m3, this.l1.b8, this.getEffectiveViewport());
        var b = (this.l1.dw(this.bs.m3.left, a));
        var c = (this.l1.dw(this.bs.m3.right, a));
        var d = null;
        if (this.l1.cc) {
            d = this.l1;
            b = d.i$f(b);
            c = d.i$f(c);
        }
        else {
            b = Math.floor(b);
            c = Math.ceil(c);
        }
        b = Math.max(0, Math.min(this.mt.count - 1, b));
        c = Math.max(0, Math.min(this.mt.count - 1, c));
        var e = 1.7976931348623157E+308;
        var f = -1.7976931348623157E+308;
        for (var g = truncate(b); g <= truncate(c); g++) {
            var h = g;
            if (d != null) {
                h = d.i$b._inner[g];
            }
            e = Math.min(e, this.mt.item(h));
            f = Math.max(f, this.mr.item(h));
        }
        return new AxisRange(e, f);
    };
    FinancialPriceSeries.prototype.ee = function () {
        return Series.ef(this.mv, typeCast(ISortingAxis_$type, this.l1));
    };
    FinancialPriceSeries.prototype.c8 = function (a) {
        var b = this.bz != null ? this.bz.indexOf(a) : -1;
        var c = this.bi.bs;
        c = c.copy();
        var d = this.bi.br;
        var e = new Rect(0, 0, 0, 1, 1);
        var f = this.ll(this.bi);
        if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
            if (this.l1 != null) {
                var g = new ScalerParams(0, e, e, this.l1.b8, f);
                var h = this.l1.dt(b, g);
                if (h < c.left + 0.1 * c.width) {
                    h = h + 0.4 * c.width;
                }
                if (h > c.right - 0.1 * c.width) {
                    h = h - 0.4 * c.width;
                }
                c.x = h - 0.5 * c.width;
            }
            if (this.mm != null && this.mt != null && this.mr != null && b < this.mt.count && b < this.mr.count) {
                var i = new ScalerParams(0, e, e, this.mm.b8, f);
                i.b = this.ee();
                var j = this.mm.dt(this.mt.item(b), i);
                var k = this.mm.dt(this.mr.item(b), i);
                if (!isNaN_(j) && !isNaN_(k)) {
                    var l = Math.abs(j - k);
                    if (c.height < l) {
                        c.height = l;
                        c.y = Math.min(j, k);
                    }
                    else {
                        if (j < c.top + 0.1 * c.height) {
                            j = j + 0.4 * c.height;
                        }
                        if (j > c.bottom - 0.1 * c.height) {
                            j = j - 0.4 * c.height;
                        }
                        c.y = j - 0.5 * c.height;
                    }
                }
            }
            this.bn.ap(this.bs, c, true);
        }
        return b >= 0;
    };
    FinancialPriceSeries.prototype.dv = function (a, b, c) {
        var d = _super.prototype.dv.call(this, a, b, c);
        if (this.mv == null || this.mp == null || this.mr == null || this.mt == null) {
            d = false;
        }
        return d;
    };
    FinancialPriceSeries.prototype.os = function (a, b) {
        var _this = this;
        var e_1, _a;
        _super.prototype.os.call(this, a, b);
        var c = b.bs;
        var d = b.br;
        var e = this.getEffectiveViewport1(b);
        var f = this.l1;
        var g = this.mm;
        var h = new ScalerParams(0, c, d, f.b8, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, g.b8, e);
            $ret.b = _this.ee();
            return $ret;
        })());
        a.f.clear();
        a.m.clear();
        a.p.clear();
        var j = 0;
        var k = typeCast(ISortingAxis_$type, this.l1);
        if (k != null && (k.i$b == null || k.i$b.count != this.bz.count)) {
            return;
        }
        j = this.ns(c, d, e);
        var l = typeCast(FinancialPriceSeriesView.$, b);
        var m = this.er;
        if (this.trendLineType != 0) {
            var n = new Array(this.bz.count);
            var o = 0;
            try {
                for (var _b = tslib_1.__values(fromEnum(this.nj)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var p = _c.value;
                    n[o] = p;
                    o++;
                }
            }
            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; }
            }
            if (this.pc.b4) {
                this.pc.b2.prepareLineCore(a.p, this.trendLineType, boxArray$1(n), this.trendLinePeriod, function (q) { return _this.l1.dt(q, h); }, function (q) { return _this.mm.dt(q, i); }, ((function () {
                    var $ret = new TrendResolutionParams();
                    $ret.c = b.bu.b;
                    $ret.d = b.bu.c;
                    $ret.e = b.bu.d;
                    $ret.a = j;
                    $ret.b = m;
                    $ret.f = d;
                    return $ret;
                })()));
            }
        }
        var q = this.l1.dw(2, h) - this.l1.dw(1, h);
        for (var r = b.bu.c; r <= b.bu.d; ++r) {
            var s = void 0;
            if (k == null) {
                s = b.bu.getBucket(r);
            }
            else {
                var t = k.i$b._inner[r];
                var u = k.i$d(t);
                var v = this.mv.item(t);
                var w = this.mr.item(t);
                var x = this.mt.item(t);
                var y = this.mp.item(t);
                var z = v;
                var aa = w;
                var ab = x;
                var ac = y;
                var ad = u;
                while (r < b.bu.d) {
                    t = k.i$b._inner[r + 1];
                    ad = k.i$d(t);
                    if (ad - u > q * m) {
                        break;
                    }
                    r++;
                    aa = Math.max(aa, this.mr.item(t));
                    ab = Math.min(ab, this.mt.item(t));
                    ac = this.mp.item(t);
                }
                var ae = NaN;
                if (!isNaN_(u)) {
                    ae = this.l1.dt(u, h);
                }
                s = [ae, z, aa, ab, ac];
            }
            if (!isNaN_(s[0])) {
                if (k != null) {
                    s[0] = s[0] + j;
                }
                else {
                    s[0] = f.dt(s[0], h) + j;
                }
                s[1] = g.dt(s[1], i);
                s[2] = g.dt(s[2], i);
                s[3] = g.dt(s[3], i);
                s[4] = g.dt(s[4], i);
                a.f.add(s);
            }
        }
        return;
    };
    FinancialPriceSeries.prototype.hp = function (a, b) {
        _super.prototype.hp.call(this, a, b);
        var c = typeCast(FinancialPriceSeriesView.$, b);
        c.b8();
        if (a) {
            c.b3.count = 0;
        }
        if (c.b4 && c.b2 != null) {
            c.b2.g$d();
        }
    };
    FinancialPriceSeries.prototype.get_m5 = function () {
        return true;
    };
    FinancialPriceSeries.prototype.ou = function (a, b) {
        _super.prototype.ou.call(this, a, b);
        if (this.l1 == null || this.mm == null) {
            return;
        }
        var c = false;
        if (b.bx(a)) {
            c = true;
            b.bz(a);
        }
        this.l9.x(this, this.m9(), this.l1, runOn(this, this.lt), this.ny(b), this.n0(b));
        var d = false;
        var e = this.l9.c;
        if (e != null) {
            d = true;
        }
        var f = typeCast(FinancialPriceSeriesView.$, b);
        f.b7();
        f.b5 = false;
        if (f.b4) {
            f.b2.g$d();
        }
        if (this.trendLineType != 0) {
            f.b2.g$g(a.p);
        }
        if (d) {
            this.pk(a, b, c);
        }
        else {
            f.b3.count = 0;
            this.pj(a, b);
        }
    };
    FinancialPriceSeries.prototype.ed = function () {
        var a = this.getEffectiveViewport1(this.bi);
        return this.pe(this.mh, a);
    };
    FinancialPriceSeries.prototype.pk = function (a, b, c) {
        var d = this.pd;
        var e = this.getEffectiveViewport1(b);
        var f = this.pe(b, e);
        var g = (f - 1) / 2;
        var h = typeCast(FinancialPriceSeriesView.$, b);
        h.b5 = true;
        var i = a.f;
        var j = 0;
        var k = this.bz.count;
        var l = this.l1;
        var m = new ScalerParams(0, b.bs, b.br, l.b8, e);
        var n = this.kw;
        var o = this.o7;
        if (o == null) {
            o = n;
        }
        var p = this.kx;
        var q = this.px;
        if (q == null) {
            q = p;
        }
        var _loop_1 = function (r) {
            var s = i._inner[r][0] - g;
            var t = i._inner[r][0];
            var u = i._inner[r][0] + g;
            var v = i._inner[r][1];
            var w = i._inner[r][2];
            var x = i._inner[r][3];
            var y = i._inner[r][4];
            if (isNaN_(v) || isNaN_(w) || isNaN_(x) || isNaN_(y)) {
                return "continue";
            }
            var z = h.b3.item(j);
            j++;
            var aa = v < y;
            var ab = new PathGeometry();
            if (c) {
                switch (d) {
                    case 0:
                        if (aa) {
                            var ac = v;
                            v = y;
                            y = ac;
                        }
                        var ad = new PathFigure();
                        ad._startPoint = { $type: Point_$type, x: t, y: x };
                        ad._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: v };
                            return $ret;
                        })()));
                        var ae = new PathFigure();
                        ae._startPoint = { $type: Point_$type, x: s, y: y };
                        ae._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: y };
                            return $ret;
                        })()));
                        ae._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: v };
                            return $ret;
                        })()));
                        ae._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: s, y: v };
                            return $ret;
                        })()));
                        ae._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: s, y: y };
                            return $ret;
                        })()));
                        var af = new PathFigure();
                        af._startPoint = { $type: Point_$type, x: t, y: y };
                        af._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: w };
                            return $ret;
                        })()));
                        ab.b.add(ad);
                        ab.b.add(ae);
                        ab.b.add(af);
                        break;
                    case 1:
                        var ag = new PathFigure();
                        ag._startPoint = { $type: Point_$type, x: s, y: v };
                        ag._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: v };
                            return $ret;
                        })()));
                        var ah = new PathFigure();
                        ah._startPoint = { $type: Point_$type, x: t, y: x };
                        ah._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: t, y: w };
                            return $ret;
                        })()));
                        var ai = new PathFigure();
                        ai._startPoint = { $type: Point_$type, x: t, y: y };
                        ai._segments.add(((function () {
                            var $ret = new LineSegment(1);
                            $ret.c = { $type: Point_$type, x: u, y: y };
                            return $ret;
                        })()));
                        ab.b.add(ag);
                        ab.b.add(ah);
                        ab.b.add(ai);
                        break;
                }
            }
            if (aa) {
                this_1.l9.al = o;
                this_1.l9.ah = o;
                this_1.l9.am = this_1.l9.ai = q;
                this_1.l9.f = true;
            }
            else {
                this_1.l9.al = n;
                this_1.l9.ah = n;
                this_1.l9.am = this_1.l9.ai = p;
                this_1.l9.f = false;
            }
            this_1.or(i, r, k, l, m, b.n);
            if (d == 1) {
                this_1.l9.ae(z, true, false, false, false);
            }
            else {
                this_1.l9.ae(z, false, false, false, false);
            }
            if (c) {
                z.aj = ab;
            }
        };
        var this_1 = this;
        for (var r = 0; r < i.count; ++r) {
            _loop_1(r);
        }
        h.b3.count = j;
        h.b9();
    };
    FinancialPriceSeries.prototype.pe = function (a, b) {
        var c = this.l1.jk(a.bs, a.br, b);
        c = Math.max(c, this.er * 0.9);
        c = Math.max(c, 3);
        return c;
    };
    FinancialPriceSeries.prototype.pj = function (a, b) {
        var c = this.pd;
        var d = this.getEffectiveViewport1(b);
        var e = this.pe(b, d);
        var f = (e - 1) / 2;
        var g = typeCast(FinancialPriceSeriesView.$, b);
        var h = g.ch();
        var i = g.cg();
        var j = a.f;
        var _loop_2 = function (k) {
            var l = j._inner[k][0] - f;
            var m = j._inner[k][0];
            var n = j._inner[k][0] + f;
            var o = j._inner[k][1];
            var p = j._inner[k][2];
            var q = j._inner[k][3];
            var r = j._inner[k][4];
            if (isNaN_(o) || isNaN_(p) || isNaN_(q) || isNaN_(r)) {
                return "continue";
            }
            var s = o < r;
            var t = s ? i : h;
            switch (c) {
                case 0:
                    if (s) {
                        var u = o;
                        o = r;
                        r = u;
                    }
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: m, y: q };
                        $ret.b = { $type: Point_$type, x: m, y: o };
                        return $ret;
                    })()));
                    t.c.add(((function () {
                        var $ret = new RectangleGeometry();
                        $ret.d = new Rect(0, l, r, n - l, o - r);
                        return $ret;
                    })()));
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: m, y: r };
                        $ret.b = { $type: Point_$type, x: m, y: p };
                        return $ret;
                    })()));
                    break;
                case 1:
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: l, y: o };
                        $ret.b = { $type: Point_$type, x: m, y: o };
                        return $ret;
                    })()));
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: m, y: q };
                        $ret.b = { $type: Point_$type, x: m, y: p };
                        return $ret;
                    })()));
                    t.c.add(((function () {
                        var $ret = new LineGeometry();
                        $ret.c = { $type: Point_$type, x: m, y: r };
                        $ret.b = { $type: Point_$type, x: n, y: r };
                        return $ret;
                    })()));
                    break;
            }
        };
        for (var k = 0; k < j.count; ++k) {
            _loop_2(k);
        }
    };
    FinancialPriceSeries.prototype.fq = function (a, b) {
        if (this.pc.b4 && a == this.pc.b2.g$j) {
            return null;
        }
        return _super.prototype.fq.call(this, a, b);
    };
    FinancialPriceSeries.prototype.jh = function () {
        _super.prototype.jh.call(this);
        if (this.fe < 0) {
            return;
        }
        this.pc.cf();
    };
    FinancialPriceSeries.prototype.hy = function (a) {
        _super.prototype.hy.call(this, a);
        if (this.pc.b4) {
            this.a2.exportTrendlineData(this, a, this.pc.b2.g$j);
        }
    };
    FinancialPriceSeries.prototype.jb = function (a, b) {
        _super.prototype.jb.call(this, a, b);
        this.px = b;
    };
    FinancialPriceSeries.$t = markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    FinancialPriceSeries.pm = DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialPriceSeries.$, new PropertyMetadata(2, null, function (a, b) { return a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue); }));
    return FinancialPriceSeries;
}(FinancialSeries));
export { FinancialPriceSeries };
Type.dep(DependencyProperty, PropertyMetadata, FinancialPriceSeries, 'raisePropertyChanged', ['DisplayType:pd:pn', [PriceDisplayType_$type, enumGetBox(PriceDisplayType_$type, 0)], 'NegativeOutline:px:po', [Brush.$, null], 'TrendLineType::pu', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::pt', [1, 1.5], 'TrendLinePeriod::ps', [1, 7], 'TrendLineBrush::pp', [Brush.$, null], 'TrendLineZIndex:pg:pv', [1, 1001], 'TrendLineDashArray:py:pq', [DoubleCollection.$], 'TrendLineDashCap:pz:pr', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
/**
 * @hidden
 */
var FinancialPriceSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(FinancialPriceSeriesView, _super);
    function FinancialPriceSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.b0 = null;
        _this.b3 = null;
        _this.b6 = null;
        _this.ck = ((function () {
            var $ret = new Path();
            $ret.aj = new GeometryGroup();
            return $ret;
        })());
        _this.cj = ((function () {
            var $ret = new Path();
            $ret.aj = new GeometryGroup();
            return $ret;
        })());
        _this.b1 = null;
        _this.ci = new Path();
        _this.b5 = false;
        _this.b0 = a;
        _this.b6 = new List$1(Path.$, 0);
        _this.b3 = ((function () {
            var $ret = new Pool$1(Path.$);
            $ret.create = runOn(_this, _this.cl);
            $ret.activate = runOn(_this, _this.cb);
            $ret.disactivate = runOn(_this, _this.cd);
            $ret.destroy = runOn(_this, _this.cc);
            return $ret;
        })());
        return _this;
    }
    FinancialPriceSeriesView.prototype.cl = function () {
        var a = new Path();
        this.b6.add(a);
        a._visibility = 1;
        return a;
    };
    FinancialPriceSeriesView.prototype.cb = function (a) {
        a._visibility = 0;
    };
    FinancialPriceSeriesView.prototype.cd = function (a) {
        a._visibility = 1;
    };
    FinancialPriceSeriesView.prototype.cc = function (a) {
        this.b6.remove(a);
    };
    FinancialPriceSeriesView.prototype.bv = function () {
        return new FinancialPriceBucketCalculator(this);
    };
    FinancialPriceSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        if (!this.n) {
            this.bw.o7 = ((function () {
                var $ret = new Brush();
                $ret.fill = "#C62828";
                return $ret;
            })());
            this.b0.px = this.bw.o7;
            this.bw.er = 5;
            this.bw.ev = 1;
        }
    };
    Object.defineProperty(FinancialPriceSeriesView.prototype, "b2", {
        get: function () {
            if (this.b1 == null) {
                this.b1 = CategoryTrendLineManagerFactory.a(this.b1, this.e.ap(), this.e.jq, this.e, this.e.b2);
            }
            return this.b1;
        },
        set: function (a) {
            this.b1 = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FinancialPriceSeriesView.prototype, "b4", {
        get: function () {
            return this.b1 != null;
        },
        enumerable: true,
        configurable: true
    });
    FinancialPriceSeriesView.prototype.ce = function () {
        if (this.b0.pd == 1) {
            this.ck._stroke = this.e.kw;
        }
        else {
            this.ck._stroke = this.e.kx;
        }
        if (this.b0.pd == 1) {
            this.cj._stroke = this.bw.o7;
        }
        else {
            this.cj._stroke = this.b0.px;
        }
    };
    FinancialPriceSeriesView.prototype.b8 = function () {
        this.an();
        this.b3.count = 0;
        this.b7();
    };
    FinancialPriceSeriesView.prototype.b7 = function () {
        var a = typeCast(GeometryGroup.$, this.ck.aj);
        var b = typeCast(GeometryGroup.$, this.cj.aj);
        Extensions.d(a);
        Extensions.d(b);
    };
    FinancialPriceSeriesView.prototype.ch = function () {
        this.an();
        return typeCast(GeometryGroup.$, this.ck.aj);
    };
    FinancialPriceSeriesView.prototype.cg = function () {
        this.an();
        return typeCast(GeometryGroup.$, this.cj.aj);
    };
    FinancialPriceSeriesView.prototype.cf = function () {
        this.b0.pw = null;
        if (this.b0.trendLineBrush != null) {
            this.b0.pw = this.b0.trendLineBrush;
        }
        else {
            this.b0.pw = this.b0.kw;
        }
    };
    FinancialPriceSeriesView.prototype.a8 = function () {
        _super.prototype.a8.call(this);
        this.ck.ac = this.e.ev;
        this.ck.ai = this.e.k4;
        this.ck.ad = this.e.k5;
        if (this.b0.pd == 1) {
            this.ck._stroke = this.e.kw;
        }
        else {
            this.ck._stroke = this.e.kx;
            this.ck._fill = this.e.kw;
        }
        this.cj.ac = this.e.ev;
        this.cj.ai = this.e.k4;
        this.cj.ad = this.e.k5;
        if (this.b0.pd == 1) {
            this.cj._stroke = this.bw.o7;
        }
        else {
            this.cj._stroke = this.b0.px;
            this.cj._fill = this.bw.o7;
        }
    };
    FinancialPriceSeriesView.prototype.a9 = function () {
        _super.prototype.a9.call(this);
        var a = this.bl();
        this.ck.ac = this.e.ev + 3;
        if (this.b0.pd == 1) {
            this.ck._stroke = a;
        }
        else {
            this.ck._stroke = a;
            this.ck._fill = a;
        }
        this.cj.ac = this.e.ev + 3;
        if (this.b0.pd == 1) {
            this.cj._stroke = a;
        }
        else {
            this.cj._stroke = a;
            this.cj._fill = a;
        }
    };
    FinancialPriceSeriesView.prototype.z = function (a) {
        return this.b6._inner[a];
    };
    FinancialPriceSeriesView.prototype.y = function (a) {
        var b = this.b6._inner[a];
        this.ci._visibility = b._visibility;
        this.ci.aj = b.aj;
        var c = this.bm(a);
        this.ci._fill = c;
        this.ci._stroke = c;
        this.ci.ac = this.e.ev + 3;
        return this.ci;
    };
    FinancialPriceSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d) {
            if (this.b5) {
                for (var c = 0; c < this.b6.count; c++) {
                    var d = this.x(c, b);
                    if (d._visibility == 0) {
                        a.s(d);
                    }
                }
            }
            else {
                a.s(this.ck);
                a.s(this.cj);
            }
        }
    };
    FinancialPriceSeriesView.prototype.a2 = function (a, b) {
        if (a.d) {
            if (this.b0.trendLineType != 0 && !b) {
                var c = this.b2.g$j;
                c.ac = this.b0.trendLineThickness;
                c._stroke = this.b0.pw;
                c.ai = this.b0.py;
                c.ad = this.b0.pz;
                a.u(c);
            }
        }
        _super.prototype.a2.call(this, a, b);
    };
    FinancialPriceSeriesView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        this.e.a2.exportPathData(a, this.ck, "positivePathShape", ["Positive", "Main"]);
        this.e.a2.exportPathData(a, this.cj, "negativePathShape", ["Negative"]);
    };
    FinancialPriceSeriesView.prototype.b9 = function () {
        this.an();
    };
    FinancialPriceSeriesView.prototype.ca = function () {
        if (this.b4) {
            this.b1 = CategoryTrendLineManagerFactory.a(this.b1, this.e.ap(), this.e.jq, this.e, this.e.b2);
        }
    };
    FinancialPriceSeriesView.$t = markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
}(FinancialSeriesView));
export { FinancialPriceSeriesView };
