/*
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 { FinancialSeries } from "./FinancialSeries";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { TrendLineType_$type } from "igniteui-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { PenLineCap_$type } from "igniteui-react-core";
import { DoubleCollection } from "igniteui-react-core";
import { PriceDisplayType_$type } from "./PriceDisplayType";
import { Series } from "./Series";
import { Defaults } from "./Defaults";
import { enumGetBox, EnumUtil, typeCast, fromEnum, runOn, Point_$type, markType, markDep } from "igniteui-react-core";
import { CategoryFrame } from "./CategoryFrame";
import { ISortingAxis_$type } from "./ISortingAxis";
import { FinancialSeriesView } from "./FinancialSeriesView";
import { Rect } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { RectUtil } from "igniteui-react-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { AxisRange } from "./AxisRange";
import { ScalerParams } from "./ScalerParams";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { Pool$1 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { PathGeometry } from "igniteui-react-core";
import { PathFigure } from "igniteui-react-core";
import { LineSegment } from "igniteui-react-core";
import { GeometryGroup } from "igniteui-react-core";
import { LineGeometry } from "igniteui-react-core";
import { RectangleGeometry } from "igniteui-react-core";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
import { boxArray$1 } from "igniteui-react-core";
import { round10N } from "igniteui-react-core";
import { FinancialPriceBucketCalculator } from "./FinancialPriceBucketCalculator";
import { Extensions } from "igniteui-react-core";
/**
 * @hidden
 */
export let FinancialPriceSeries = /*@__PURE__*/ (() => {
    class FinancialPriceSeries extends FinancialSeries {
        get_en() {
            return true;
        }
        ip() {
            if (!isNaN_(this.io)) {
                return super.ip();
            }
            return Defaults.k;
        }
        cg() {
            return new FinancialPriceSeriesView(this);
        }
        o0(a) {
            super.o0(a);
            this.x4 = a;
        }
        constructor() {
            super();
            this.x6 = true;
            this.x7 = 0;
            this.x8 = 0;
            this.ab = FinancialPriceSeries.$;
            this.ud = new CategoryFrame(5);
            this.uf = new CategoryFrame(5);
            this.ub = new CategoryFrame(5);
        }
        get zg() {
            return this.c(FinancialPriceSeries.yy);
        }
        set zg(a) {
            this.h(FinancialPriceSeries.yy, a);
        }
        no(a, b, c, d) {
            super.no(a, b, c, d);
            if (this.t9 != null && typeCast(ISortingAxis_$type, this.t9) !== null) {
                this.t9.i$i();
            }
            this.x4.b0.e(this.hj);
            if (this.x4.ca) {
                this.x4.b8.g$e(a, b, c, d);
            }
            if (this.uv != null) {
                this.uv.c1();
            }
            this.pp(true);
            if (a == 0 || a == 2 || a == 3 || a == 4) {
                this.x6 = true;
            }
            else if (a == 1) {
                for (let e = b; e < b + c; e++) {
                    let f = 0;
                    f += this.u3.item(e);
                    f += this.u4.item(e);
                    f += this.u2.item(e);
                    this.x7 += f / 3;
                }
                this.x8 = this.x7 / this.u3.count;
            }
        }
        bx() {
            if (this.by == 0) {
                return 1;
            }
            else {
                return super.bx();
            }
        }
        ts(a) {
            if (this.ub == null || this.ub.f.count == 0) {
                return Rect.empty;
            }
            let b = this.tc(a);
            let c = this.cj.by;
            let d = this.cj.bx;
            let e = this.getEffectiveViewport1(this.cj);
            let f = this.aj(this.t9, this.ub.f, this.v6(this.cj), this.v8(this.cj), a, true);
            let g = f[0];
            let h = f[1];
            let i = Math.abs(b.x - g[0]);
            let j = Math.abs(b.x - h[0]);
            let k = this.x9(this.uq, e);
            k = Math.max(k, 3);
            let l = (k - 1) / 2;
            if (i < j) {
                let m = g[0] - l;
                let n = g[0];
                let o = g[0] + l;
                let p = g[1];
                let q = g[2];
                let r = g[3];
                let s = g[4];
                let t = Math.min(Math.min(Math.min(p, q), r), s);
                let u = Math.max(Math.max(Math.max(p, q), r), s);
                return new Rect(0, m, t, Math.abs(o - m), u - t);
            }
            else {
                let v = h[0] - l;
                let w = h[0];
                let x = h[0] + l;
                let y = h[1];
                let z = h[2];
                let aa = h[3];
                let ab = h[4];
                let ac = Math.min(Math.min(Math.min(y, z), aa), ab);
                let ad = Math.max(Math.max(Math.max(y, z), aa), ab);
                return new Rect(0, v, ac, Math.abs(x - v), ad - ac);
            }
        }
        x3(a, b) {
            let c = a[0] - b;
            let d = a[0];
            let e = a[0] + b;
            let f = a[1];
            let g = a[2];
            let h = a[3];
            let i = a[4];
            let j = Math.min(Math.min(Math.min(f, g), h), i);
            let k = Math.max(Math.max(Math.max(f, g), h), i);
            let l = Math.min(g, h);
            let m = Math.max(g, h);
            let n = Math.min(f, i);
            let o = Math.max(f, i);
            if (this.x5 == 1) {
                let p = new Array(3);
                let q = new Rect(0, c, f, b, 0);
                let r = new Rect(0, d, i, b, 0);
                let s = new Rect(0, d, l, 0, m - l);
                p[0] = q;
                p[1] = r;
                p[2] = s;
                return p;
            }
            else {
                let t = new Array(2);
                let u = new Rect(0, d, l, 0, m - l);
                let v = new Rect(0, c, n, b * 2, o - n);
                t[0] = u;
                t[1] = v;
                return t;
            }
        }
        ak(a) {
            let b = new List$1(Rect.$, 0);
            let c = this.tc(a);
            let d = this.cj.by;
            let e = this.cj.bx;
            let f = this.getEffectiveViewport1(this.cj);
            let g = this.aj(this.t9, this.ub.f, this.v6(this.cj), this.v8(this.cj), a, true);
            let h = g[0];
            let i = g[1];
            let j = Math.abs(c.x - h[0]);
            let k = Math.abs(c.x - i[0]);
            let l = this.x9(this.uq, f);
            l = Math.max(l, 3);
            let m = (l - 1) / 2;
            if (j < k) {
                return this.x3(h, m);
            }
            else {
                return this.x3(i, m);
            }
        }
        f4(a, b) {
            if (this.f7(a, b)) {
                return true;
            }
            return false;
        }
        f7(a, b) {
            let c = this.tt(a);
            if (c.isEmpty) {
                return false;
            }
            let d = RectUtil.r(c, (this.hk / 2) + this.hy(b));
            if (d.containsPoint(a)) {
                let e = this.al(a);
                if (e != null) {
                    for (let f = 0; f < e.length; f++) {
                        let g = e[f];
                        let h = RectUtil.r(g, (this.hk / 2) + this.hy(b));
                        if (h.containsPoint(a)) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
        o8(a, b, c, d) {
            switch (b) {
                case FinancialSeries.$$p[14]:
                    this.x4.cg();
                    if (this.cy != null) {
                        this.cy.mf();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.x4.b8 = CategoryTrendLineManagerFactory.a(this.x4.b8, this.t9, this.qr, this, this.c9);
                    }
                    break;
            }
            super.o8(a, b, c, d);
            if (this.x4.ca && this.x4.b8 != null && this.x4.b8.g$b(a, b, c, d)) {
                this.pp(false);
                this.ol();
            }
            switch (b) {
                case FinancialPriceSeries.$$p[2]:
                    if (this.qr != null) {
                        this.yx();
                        this.qe();
                        this.ub.w();
                        this.xh(this.ub, this.x4);
                    }
                    this.ol();
                    break;
                case "ActualHighlightingMode":
                    this.pp(true);
                    break;
                case "TrendLineBrush":
                    this.pe(b);
                    break;
                case "TrendLineType":
                    this.ol();
                    break;
                case FinancialSeries.$$p[10]:
                case FinancialPriceSeries.$$p[7]:
                    this.o2();
                    break;
            }
        }
        yx() {
            this.x4.ck();
            if (this.ci != null) {
                this.ci.ck();
            }
        }
        aq(a) {
            if (a != null && a == this.uv && this.u4 != null && !isNaN_(this.u4.minimum) && this.u3 != null && !isNaN_(this.u3.maximum)) {
                return new AxisRange(this.u4.minimum, this.u3.maximum);
            }
            return null;
        }
        ar(a) {
            if (a.isEmpty && this.cy != null) {
                a = this.cy.tn;
            }
            if (this.u4 == null || this.u3 == null) {
                return null;
            }
            let b = this.to(this.cj);
            let c = new ScalerParams(0, a, this.cy.t2, this.t9.ch, this.getEffectiveViewport());
            let d = (this.t9.em(b.left, c));
            let e = (this.t9.em(b.right, c));
            if (this.t9.ch) {
                let f = d;
                d = e;
                e = f;
            }
            let g = null;
            if (this.t9.cn) {
                g = this.t9;
                d = g.i$f(d);
                e = g.i$f(e);
            }
            else {
                d = Math.floor(d);
                e = Math.ceil(e);
            }
            d = Math.max(0, Math.min(this.u4.count - 1, d));
            e = Math.max(0, Math.min(this.u4.count - 1, e));
            let h = 1.7976931348623157E+308;
            let i = -1.7976931348623157E+308;
            for (let j = truncate(d); j <= truncate(e); j++) {
                let k = j;
                if (g != null) {
                    k = g.i$b._inner[j];
                }
                let l = this.u4.item(k);
                if (this.u4.mayContainUnknowns) {
                    if (isInfinity(l) || isNaN_(l)) {
                        continue;
                    }
                }
                let m = this.u3.item(k);
                if (this.u3.mayContainUnknowns) {
                    if (isInfinity(m) || isNaN_(m)) {
                        continue;
                    }
                }
                h = Math.min(h, l);
                i = Math.max(i, m);
            }
            let n = new AxisRange(h, i);
            n = this.ap(n, this.uv, a);
            return n;
        }
        h2() {
            return Series.h3(this.u5, typeCast(ISortingAxis_$type, this.t9));
        }
        fo(a) {
            let b = this.c6 != null ? this.c6.indexOf(a) : -1;
            let c = this.cj.by;
            c = c.copy();
            let d = this.cj.bx;
            let e = new Rect(0, 0, 0, 1, 1);
            let f = this.tq(this.cj);
            if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
                if (this.t9 != null) {
                    let g = new ScalerParams(0, e, e, this.t9.ch, f);
                    let h = this.t9.ej(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.uv != null && this.u4 != null && this.u3 != null && b < this.u4.count && b < this.u3.count) {
                    let i = new ScalerParams(0, e, e, this.uv.ch, f);
                    i.b = this.h2();
                    let j = this.uv.ej(this.u4.item(b), i);
                    let k = this.uv.ej(this.u3.item(b), i);
                    if (!isNaN_(j) && !isNaN_(k)) {
                        let 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.cr.au(this.cy, c, true);
            }
            return b >= 0;
        }
        gl(a, b, c) {
            let d = super.gl(a, b, c);
            if (this.u5 == null || this.u2 == null || this.u3 == null || this.u4 == null) {
                d = false;
            }
            return d;
        }
        xf(a, b) {
            super.xf(a, b);
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = this.t9;
            let g = this.uv;
            let h = new ScalerParams(0, c, d, f.ch, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, g.ch, e);
                $ret.b = this.h2();
                return $ret;
            })());
            let j = this.t9.ag();
            let k = j[0];
            let l = j[1];
            a.f.clear();
            a.m.clear();
            a.p.clear();
            let m = 0;
            let n = typeCast(ISortingAxis_$type, this.t9);
            if (n != null && (n.i$b == null || n.i$b.count != this.c6.count)) {
                return;
            }
            m = this.v0(c, d, e);
            let o = typeCast(FinancialPriceSeriesView.$, b);
            let p = this.hj;
            if (this.trendLineType != 0) {
                let q = new Array(this.c6.count);
                let r = 0;
                for (let s of fromEnum(this.vr)) {
                    q[r] = s;
                    r++;
                }
                if (this.x4.ca) {
                    this.x4.b8.prepareLineCore(a.p, this.trendLineType, boxArray$1(q), this.trendLinePeriod, (t) => this.t9.ej(t, h), (t) => this.uv.ej(t, i), ((() => {
                        let $ret = new TrendResolutionParams();
                        $ret.e = b.b0.b;
                        $ret.f = b.b0.c;
                        $ret.g = b.b0.d;
                        $ret.a = m;
                        $ret.d = p;
                        $ret.h = d;
                        $ret.c = k;
                        $ret.b = l;
                        return $ret;
                    })()));
                }
            }
            let t = this.t9.em(2, h) - this.t9.em(1, h);
            for (let u = b.b0.c; u <= b.b0.d; ++u) {
                let v;
                if (n == null) {
                    v = b.b0.getBucket(u);
                }
                else {
                    let w = n.i$b._inner[u];
                    let x = n.i$d(w);
                    let y = this.u5.item(w);
                    let z = this.u3.item(w);
                    let aa = this.u4.item(w);
                    let ab = this.u2.item(w);
                    let ac = y;
                    let ad = z;
                    let ae = aa;
                    let af = ab;
                    let ag = x;
                    while (u < b.b0.d) {
                        w = n.i$b._inner[u + 1];
                        ag = n.i$d(w);
                        if (ag - x > t * p) {
                            break;
                        }
                        u++;
                        ad = Math.max(ad, this.u3.item(w));
                        ae = Math.min(ae, this.u4.item(w));
                        af = this.u2.item(w);
                    }
                    let ah = NaN;
                    if (!isNaN_(x)) {
                        ah = this.t9.ej(x, h);
                    }
                    v = [ah, ac, ad, ae, af];
                }
                if (!isNaN_(v[0])) {
                    if (n != null) {
                        v[0] = v[0] + m;
                    }
                    else {
                        v[0] = f.ej(v[0], h) + m;
                    }
                    v[1] = g.ej(v[1], i);
                    v[2] = g.ej(v[2], i);
                    v[3] = g.ej(v[3], i);
                    v[4] = g.ej(v[4], i);
                    a.f.add(v);
                }
            }
            return;
        }
        nj(a, b) {
            super.nj(a, b);
            let c = typeCast(FinancialPriceSeriesView.$, b);
            c.ce();
            if (a) {
                c.b9.count = 0;
            }
            if (c.ca && c.b8 != null) {
                c.b8.g$d();
            }
        }
        qm(a, b) {
            super.qm(a, b);
            if (this.cy != null) {
                this.cy.mf();
            }
        }
        ty(a, b) {
            if (this.t9 != null && this.t9.categoryMode == 0) {
                let c = this.getEffectiveViewport1(this.cj);
                let d = this.x9(this.uq, c) / 2;
                return new Thickness(1, d, 0, d, 0);
            }
            return super.ty(a, b);
        }
        get_du() {
            return true;
        }
        xh(a, b) {
            super.xh(a, b);
            if (this.t9 == null || this.uv == null) {
                return;
            }
            let c = false;
            if (b.b3(a)) {
                c = true;
                b.b5(a);
            }
            this.ui.a2(this, this.vh(), runOn(this, this.t1), this.v6(b), this.v8(b));
            let d = false;
            let e = this.ui.b;
            if (e != null) {
                d = true;
            }
            let f = typeCast(FinancialPriceSeriesView.$, b);
            f.cd();
            f.cb = false;
            if (f.ca) {
                f.b8.g$d();
            }
            if (this.trendLineType != 0) {
                f.b8.g$g(a.p);
            }
            if (d) {
                this.yv(a, b, c);
            }
            else {
                f.b9.count = 0;
                this.yu(a, b);
            }
        }
        h0() {
            let a = this.getEffectiveViewport1(this.cj);
            return this.x9(this.uq, a);
        }
        yv(a, b, c) {
            let d = this.x5;
            let e = this.getEffectiveViewport1(b);
            let f = this.x9(b, e);
            let g = (f - 1) / 2;
            let h = typeCast(FinancialPriceSeriesView.$, b);
            h.cb = true;
            let i = a.f;
            let j = 0;
            let k = this.c6.count;
            let l = this.t9;
            let m = new ScalerParams(0, b.by, b.bx, l.ch, e);
            let n = this.ss;
            let o = this.xz;
            if (o == null) {
                o = n;
            }
            let p = this.sv;
            let q = this.zh;
            if (q == null) {
                q = p;
            }
            for (let r = 0; r < i.count; ++r) {
                let s = i._inner[r][0] - g;
                let t = i._inner[r][0];
                let u = i._inner[r][0] + g;
                let v = i._inner[r][1];
                let w = i._inner[r][2];
                let x = i._inner[r][3];
                let y = i._inner[r][4];
                if (isNaN_(v) || isNaN_(w) || isNaN_(x) || isNaN_(y)) {
                    continue;
                }
                let z = h.b9.item(j);
                j++;
                let aa = v < y;
                let ab = new PathGeometry();
                if (c) {
                    switch (d) {
                        case 0:
                            if (aa) {
                                let ac = v;
                                v = y;
                                y = ac;
                            }
                            let ad = new PathFigure();
                            ad._startPoint = { $type: Point_$type, x: t, y: x };
                            ad._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: v };
                                return $ret;
                            })()));
                            let ae = new PathFigure();
                            ae._startPoint = { $type: Point_$type, x: s, y: y };
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: y };
                                return $ret;
                            })()));
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: v };
                                return $ret;
                            })()));
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: s, y: v };
                                return $ret;
                            })()));
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: s, y: y };
                                return $ret;
                            })()));
                            let af = new PathFigure();
                            af._startPoint = { $type: Point_$type, x: t, y: y };
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: w };
                                return $ret;
                            })()));
                            ab.c.add(ad);
                            ab.c.add(ae);
                            ab.c.add(af);
                            break;
                        case 1:
                            let ag = new PathFigure();
                            ag._startPoint = { $type: Point_$type, x: s, y: v };
                            ag._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: v };
                                return $ret;
                            })()));
                            let ah = new PathFigure();
                            ah._startPoint = { $type: Point_$type, x: t, y: x };
                            ah._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: w };
                                return $ret;
                            })()));
                            let ai = new PathFigure();
                            ai._startPoint = { $type: Point_$type, x: t, y: y };
                            ai._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: y };
                                return $ret;
                            })()));
                            ab.c.add(ag);
                            ab.c.add(ah);
                            ab.c.add(ai);
                            break;
                    }
                }
                if (aa) {
                    this.ui.ak = o;
                    this.ui.ag = o;
                    this.ui.ah = q;
                    this.ui.al = q;
                    this.ui.f = true;
                }
                else {
                    this.ui.ak = n;
                    this.ui.ag = n;
                    this.ui.ah = p;
                    this.ui.al = p;
                    this.ui.f = false;
                }
                this.xe(i, r, k, l, m, b.q);
                if (d == 1) {
                    this.ui.ad(z, true, false, false, false);
                }
                else {
                    this.ui.ad(z, false, false, false, false);
                }
                if (c) {
                    z.an = ab;
                }
            }
            h.b9.count = j;
            h.cf();
        }
        x9(a, b) {
            let c = this.t9.k4(a.by, a.bx, b);
            c = Math.max(c, this.hj * 0.9);
            c = Math.max(c, 3);
            return c;
        }
        yu(a, b) {
            let c = this.x5;
            let d = this.getEffectiveViewport1(b);
            let e = this.x9(b, d);
            let f = (e - 1) / 2;
            let g = typeCast(FinancialPriceSeriesView.$, b);
            let h = g.cn();
            let i = g.cm();
            let j = a.f;
            for (let k = 0; k < j.count; ++k) {
                let l = j._inner[k][0] - f;
                let m = j._inner[k][0];
                let n = j._inner[k][0] + f;
                let o = j._inner[k][1];
                let p = j._inner[k][2];
                let q = j._inner[k][3];
                let r = j._inner[k][4];
                if (isNaN_(o) || isNaN_(p) || isNaN_(q) || isNaN_(r)) {
                    continue;
                }
                let s = o < r;
                let t = s ? i : h;
                switch (c) {
                    case 0:
                        if (s) {
                            let u = o;
                            o = r;
                            r = u;
                        }
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: q };
                            $ret.c = { $type: Point_$type, x: m, y: o };
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new RectangleGeometry();
                            $ret.e = new Rect(0, l, r, n - l, o - r);
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: r };
                            $ret.c = { $type: Point_$type, x: m, y: p };
                            return $ret;
                        })()));
                        break;
                    case 1:
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: l, y: o };
                            $ret.c = { $type: Point_$type, x: m, y: o };
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: q };
                            $ret.c = { $type: Point_$type, x: m, y: p };
                            return $ret;
                        })()));
                        t.d.add(((() => {
                            let $ret = new LineGeometry();
                            $ret.d = { $type: Point_$type, x: m, y: r };
                            $ret.c = { $type: Point_$type, x: n, y: r };
                            return $ret;
                        })()));
                        break;
                }
            }
        }
        jy(a, b) {
            if (this.x4.ca && a == this.x4.b8.g$j) {
                return null;
            }
            return super.jy(a, b);
        }
        qd() {
            super.qd();
            if (this.index < 0) {
                return;
            }
            this.x4.cl();
        }
        n1(a) {
            super.n1(a);
            if (this.x4.ca) {
                this.a9.exportTrendlineData(this, a, this.x4.b8.g$j);
            }
        }
        s4() {
            return this.zh;
        }
        pz(a, b) {
            super.pz(a, b);
            this.zh = b;
        }
        bb(a) {
            if (this.x5 == 0) {
                return 3;
            }
            else if (this.x5 == 1) {
                if (this.ba == 1) {
                    return 3;
                }
                return 2;
            }
            return a;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.h7(c, false, false);
            let e = this.h5(c, false, false);
            let f = new DataLegendSeriesValueInfo();
            f.a = 4;
            f.l = this.v1(c, false, false);
            f.p = "Close";
            f.q = this.wd != null ? this.wd : "Close";
            f.r = this.yc != null ? this.yc : "C:";
            f.s = this.ye != null ? this.ye : "";
            let g = new DataLegendSeriesValueInfo();
            g.l = this.v2(c, false, false);
            g.a = 3;
            g.p = "Open";
            g.q = this.wz != null ? this.wz : "Open";
            g.r = this.yq != null ? this.yq : "O:";
            g.s = this.ys != null ? this.ys : "";
            g.k = true;
            let h = new DataLegendSeriesValueInfo();
            h.l = (f.l - g.l) / g.l * 100;
            h.l = round10N(h.l, 1);
            h.a = 9;
            h.p = "Change";
            h.q = "Change";
            h.r = "";
            h.u = "";
            h.w = "+";
            h.v = "%";
            h.x = "%";
            h.s = null;
            h.c = false;
            h.k = true;
            h.e = false;
            h.f = true;
            h.h = false;
            h.g = false;
            h.d = false;
            h.n = 1;
            h.m = 1;
            g.y = h.l >= 0 ? this.ss : this.xz;
            f.y = h.l >= 0 ? this.ss : this.xz;
            h.y = h.l >= 0 ? this.ss : this.xz;
            let i = new DataLegendSeriesValueInfo();
            i.l = e > d ? d : e;
            i.a = 1;
            i.p = "Low";
            i.q = this.wv != null ? this.wv : "Low";
            i.r = this.yl != null ? this.yl : "L:";
            i.s = this.yn != null ? this.yn : "";
            i.k = true;
            let j = new DataLegendSeriesValueInfo();
            j.l = e > d ? e : d;
            j.a = 2;
            j.p = "High";
            j.q = this.wq != null ? this.wq : "High";
            j.r = this.yh != null ? this.yh : "H:";
            j.s = this.yj != null ? this.yj : "";
            j.k = true;
            let k = new DataLegendSeriesValueInfo();
            k.l = (j.l + i.l + f.l) / 3;
            k.l = round10N(k.l, 2);
            k.a = 5;
            k.p = "TypicalPrice";
            k.q = "TypicalPrice";
            k.r = "TP:";
            k.s = "";
            k.k = true;
            let l = new DataLegendSeriesValueInfo();
            l.l = this.v3(c, false, false);
            l.a = 8;
            l.p = "Volume";
            l.q = this.w3 != null ? this.w3 : "Volume";
            l.r = "VOL:";
            l.s = "";
            l.k = true;
            l.n = 0;
            l.m = 0;
            l.e = false;
            l.f = false;
            l.h = false;
            let m = new List$1(DataLegendSeriesValueInfo.$, 0);
            m.add(g);
            m.add(j);
            m.add(i);
            m.add(f);
            m.add(k);
            m.add(h);
            m.add(l);
            let n = new DataLegendSeriesContext();
            n.b = this.aw();
            n.f = m;
            return n;
        }
        yw() {
            if (this.x6) {
                this.x7 = 0;
                for (let a = 0; a < this.u3.count; a++) {
                    let b = 0;
                    b += this.u3.item(a);
                    b += this.u4.item(a);
                    b += this.u2.item(a);
                    this.x7 += b / 3;
                }
                this.x8 = this.x7 / this.u3.count;
                this.x6 = false;
            }
        }
        am(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.u3.maximum;
                    break;
                case 1:
                    b = this.u4.minimum;
                    break;
                case 3:
                    if (this.x6) {
                        this.yw();
                    }
                    b = this.x8;
                    break;
            }
            let c = this.uv;
            if (c.cp) {
                return [NaN, b];
            }
            else {
                return [b, NaN];
            }
        }
        tk(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.u3.maximum;
                    break;
                case 1:
                    b = this.u4.minimum;
                    break;
                case 3:
                    if (this.x6) {
                        this.yw();
                    }
                    b = this.x8;
                    break;
            }
            if (isNaN_(b)) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let c = this.uv;
            let d = this.getEffectiveViewport1(this.cj);
            let e = new ScalerParams(0, this.cj.by, this.cj.bx, c.ch, d);
            if (c.cp) {
                e.b = this.h2();
            }
            e.c = d;
            if (c.cp) {
                return { $type: Point_$type, x: NaN, y: c.ej(b, e) };
            }
            else {
                return { $type: Point_$type, x: c.ej(b, e), y: NaN };
            }
        }
        tl(a) {
            let b = this.uv;
            let c = this.getEffectiveViewport1(this.cj);
            let d = new ScalerParams(0, this.cj.by, this.cj.bx, b.ch, c);
            if (b.cp) {
                d.b = this.h2();
            }
            d.c = c;
            if (b.cp) {
                return { $type: Point_$type, x: NaN, y: b.ej(a[1], d) };
            }
            else {
                return { $type: Point_$type, x: b.ej(a[0], d), y: NaN };
            }
        }
    }
    FinancialPriceSeries.$t = /*@__PURE__*/ markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    FinancialPriceSeries.yy = /*@__PURE__*/ DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialPriceSeries.$, /*@__PURE__*/ new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
    FinancialPriceSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, FinancialPriceSeries, 'raisePropertyChanged', ['CloseMemberAsLegendLabel:yc:yz', [2, null], 'CloseMemberAsLegendUnit:ye:y0', [2, null], 'DisplayType:x5:y1', [PriceDisplayType_$type, /*@__PURE__*/ enumGetBox(PriceDisplayType_$type, 0)], 'HighMemberAsLegendLabel:yh:y2', [2, null], 'HighMemberAsLegendUnit:yj:y3', [2, null], 'LowMemberAsLegendLabel:yl:y4', [2, null], 'LowMemberAsLegendUnit:yn:y5', [2, null], 'NegativeOutline:zh:y6', [Brush.$, null], 'OpenMemberAsLegendLabel:yq:y7', [2, null], 'OpenMemberAsLegendUnit:ys:y8', [2, null], 'TrendLineType::ze', [TrendLineType_$type, /*@__PURE__*/ enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::zd', [1, 1.5], 'TrendLinePeriod::zc', [1, 7], 'TrendLineBrush::y9', [Brush.$, null], 'TrendLineZIndex:yb:zf', [1, 1001], 'TrendLineDashArray:zi:za', [DoubleCollection.$], 'TrendLineDashCap:zj:zb', [PenLineCap_$type, /*@__PURE__*/ enumGetBox(PenLineCap_$type, 0)]]);
    return FinancialPriceSeries;
})();
/**
 * @hidden
 */
export let FinancialPriceSeriesView = /*@__PURE__*/ (() => {
    class FinancialPriceSeriesView extends FinancialSeriesView {
        constructor(a) {
            super(a);
            this.b6 = null;
            this.b9 = null;
            this.cc = null;
            this.cq = ((() => {
                let $ret = new Path();
                $ret.an = new GeometryGroup();
                return $ret;
            })());
            this.cp = ((() => {
                let $ret = new Path();
                $ret.an = new GeometryGroup();
                return $ret;
            })());
            this.b7 = null;
            this.co = new Path();
            this.cb = false;
            this.b6 = a;
            this.cc = new List$1(Path.$, 0);
            this.b9 = ((() => {
                let $ret = new Pool$1(Path.$);
                $ret.create = runOn(this, this.cr);
                $ret.activate = runOn(this, this.ch);
                $ret.disactivate = runOn(this, this.cj);
                $ret.destroy = runOn(this, this.ci);
                return $ret;
            })());
        }
        cr() {
            let a = new Path();
            this.cc.add(a);
            a._visibility = 1;
            return a;
        }
        ch(a) {
            a._visibility = 0;
        }
        cj(a) {
            a._visibility = 1;
        }
        ci(a) {
            this.cc.remove(a);
        }
        b1() {
            return new FinancialPriceBucketCalculator(this);
        }
        au() {
            super.au();
            if (!this.q) {
                this.b6.x5 = Defaults.g;
                this.b6.xz = Defaults.ah;
                this.b6.zh = Defaults.ai;
                this.b6.iu = Defaults.l;
                this.b6.s2 = this.b6.sv;
            }
        }
        get b8() {
            if (this.b7 == null) {
                this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.as(), this.e.qr, this.e, this.e.c9);
            }
            return this.b7;
        }
        set b8(a) {
            this.b7 = a;
        }
        get ca() {
            return this.b7 != null;
        }
        ck() {
            if (this.b6.x5 == 1) {
                this.cq._stroke = this.e.ss;
            }
            else {
                this.cq._stroke = this.e.sv;
            }
            if (this.b6.x5 == 1) {
                this.cp._stroke = this.b2.xz;
            }
            else {
                this.cp._stroke = this.b6.zh;
            }
        }
        ce() {
            this.as();
            this.b9.count = 0;
            this.cd();
        }
        cd() {
            let a = typeCast(GeometryGroup.$, this.cq.an);
            let b = typeCast(GeometryGroup.$, this.cp.an);
            Extensions.d(a);
            Extensions.d(b);
        }
        cn() {
            this.as();
            return typeCast(GeometryGroup.$, this.cq.an);
        }
        cm() {
            this.as();
            return typeCast(GeometryGroup.$, this.cp.an);
        }
        cl() {
            this.b6.zg = null;
            if (this.b6.trendLineBrush != null) {
                this.b6.zg = this.b6.trendLineBrush;
            }
            else {
                this.b6.zg = this.b6.ss;
            }
        }
        bd() {
            super.bd();
            this.cq.ad = this.e.hk;
            this.cq.ai = this.e.s7;
            this.cq.aj = this.e.s8;
            if (this.b6.x5 == 1) {
                this.cq._stroke = this.e.ss;
            }
            else {
                this.cq._stroke = this.e.sv;
                this.cq._fill = this.e.ss;
            }
            this.cp.ad = this.e.hk;
            this.cp.ai = this.e.s7;
            this.cp.aj = this.e.s8;
            if (this.b6.x5 == 1) {
                this.cp._stroke = this.b2.xz;
            }
            else {
                this.cp._stroke = this.b6.zh;
                this.cp._fill = this.b2.xz;
            }
        }
        be() {
            super.be();
            let a = this.br();
            this.cq.ad = this.e.hk + 3;
            if (this.b6.x5 == 1) {
                this.cq._stroke = a;
            }
            else {
                this.cq._stroke = a;
                this.cq._fill = a;
            }
            this.cp.ad = this.e.hk + 3;
            if (this.b6.x5 == 1) {
                this.cp._stroke = a;
            }
            else {
                this.cp._stroke = a;
                this.cp._fill = a;
            }
        }
        ac(a) {
            return this.cc._inner[a];
        }
        ab(a) {
            let b = this.cc._inner[a];
            this.co._visibility = b._visibility;
            this.co.an = b.an;
            let c = this.bs(a);
            this.co._fill = c;
            this.co._stroke = c;
            this.co.ad = this.e.hk + 3;
            return this.co;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                if (this.cb) {
                    for (let c = 0; c < this.cc.count; c++) {
                        let d = this.aa(c, b);
                        if (d._visibility == 0) {
                            a.t(d);
                        }
                    }
                }
                else {
                    a.t(this.cq);
                    a.t(this.cp);
                }
            }
        }
        a7(a, b) {
            if (a.d) {
                if (this.b6.trendLineType != 0 && !b) {
                    let c = this.b8.g$j;
                    c.ad = this.b6.trendLineThickness;
                    c._stroke = this.b6.zg;
                    c.ai = this.b6.zi;
                    c.aj = this.b6.zj;
                    a.v(c);
                }
            }
            super.a7(a, b);
        }
        an(a) {
            super.an(a);
            if (this.b6.vh()) {
                for (let b = 0; b < this.cc.count; b++) {
                    let c = this.cc._inner[b];
                    if (c._fill == this.b6.xz) {
                        this.e.a9.exportPathData(a, c, "negativePathShape" + b, ["Negative"]);
                    }
                    else {
                        this.e.a9.exportPathData(a, c, "positivePathShape" + b, ["Positive", "Main"]);
                    }
                }
            }
            else {
                this.e.a9.exportPathData(a, this.cq, "positivePathShape", ["Positive", "Main"]);
                this.e.a9.exportPathData(a, this.cp, "negativePathShape", ["Negative"]);
            }
        }
        cf() {
            this.as();
        }
        cg() {
            if (this.ca) {
                this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.as(), this.e.qr, this.e, this.e.c9);
            }
        }
    }
    FinancialPriceSeriesView.$t = /*@__PURE__*/ markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
})();
