/*
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-angular-core";
import { DependencyProperty } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { PenLineCap_$type } from "igniteui-angular-core";
import { DoubleCollection } from "igniteui-angular-core";
import { PriceDisplayType_$type } from "./PriceDisplayType";
import { CategoryCollisionMode_$type } from "./CategoryCollisionMode";
import { Series } from "./Series";
import { Defaults } from "./Defaults";
import { enumGetBox, EnumUtil, Number_$type, typeCast, fromEnum, runOn, Point_$type, markType, markDep } from "igniteui-angular-core";
import { CategoryFrame } from "./CategoryFrame";
import { ISortingAxis_$type } from "./ISortingAxis";
import { FinancialSeriesView } from "./FinancialSeriesView";
import { Rect } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { RectUtil } from "igniteui-angular-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { AxisRange } from "./AxisRange";
import { ScalerParams } from "./ScalerParams";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { Pool$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { PathGeometry } from "igniteui-angular-core";
import { PathFigure } from "igniteui-angular-core";
import { LineSegment } from "igniteui-angular-core";
import { GeometryGroup } from "igniteui-angular-core";
import { LineGeometry } from "igniteui-angular-core";
import { RectangleGeometry } from "igniteui-angular-core";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { ChartSelection } from "./ChartSelection";
import { PropertyMetadata } from "igniteui-angular-core";
import { truncate, isNaN_, isInfinity } from "igniteui-angular-core";
import { boxArray$1 } from "igniteui-angular-core";
import { round10N } from "igniteui-angular-core";
import { FinancialPriceBucketCalculator } from "./FinancialPriceBucketCalculator";
import { Extensions } from "igniteui-angular-core";
/**
 * @hidden
 */
export let FinancialPriceSeries = /*@__PURE__*/ (() => {
    class FinancialPriceSeries extends FinancialSeries {
        constructor() {
            super();
            this.aa2 = true;
            this.aa3 = 0;
            this.aa4 = 0;
            this.ab = FinancialPriceSeries.$;
            this.w8 = new CategoryFrame(5);
            this.xa = new CategoryFrame(5);
            this.w6 = new CategoryFrame(5);
        }
        bj() {
            return new FinancialPriceSeries();
        }
        get_e9() {
            return true;
        }
        jk() {
            if (!isNaN_(this.jj)) {
                return super.jk();
            }
            return Defaults.k;
        }
        cs() {
            return new FinancialPriceSeriesView(this);
        }
        qz(a) {
            super.qz(a);
            this.aa0 = a;
        }
        get acj() {
            return this.c(FinancialPriceSeries.ab0);
        }
        set acj(a) {
            this.h(FinancialPriceSeries.ab0, a);
        }
        pb(a, b, c, d) {
            super.pb(a, b, c, d);
            if (this.w4 != null && typeCast(ISortingAxis_$type, this.w4) !== null) {
                this.w4.i$i();
            }
            this.aa0.b0.e(this.id);
            if (this.aa0.ca) {
                this.aa0.b8.g$e(a, b, c, d);
            }
            if (this.xn != null) {
                this.xn.c1();
            }
            this.rp(true);
            if (a == 0 || a == 2 || a == 3 || a == 4) {
                this.aa2 = true;
            }
            else if (a == 1) {
                for (let e = b; e < b + c; e++) {
                    let f = 0;
                    f += this.xy.item(e);
                    f += this.xz.item(e);
                    f += this.xx.item(e);
                    this.aa3 += f / 3;
                }
                this.aa4 = this.aa3 / this.xy.count;
            }
        }
        b2() {
            if (this.b3 == 0) {
                return 1;
            }
            else {
                return super.b2();
            }
        }
        wl(a) {
            if (this.w6 == null || this.w6.f.count == 0) {
                return Rect.empty;
            }
            let b = this.v5(a);
            let c = this.cv.by;
            let d = this.cv.bx;
            let e = this.getEffectiveViewport1(this.cv);
            let f = this.an(this.w4, this.w6.f, this.y1(this.cv), this.y3(this.cv), 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.aa5(this.xl, 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);
            }
        }
        aay(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.aa1 == 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;
            }
        }
        ao(a) {
            let b = new List$1(Rect.$, 0);
            let c = this.v5(a);
            let d = this.cv.by;
            let e = this.cv.bx;
            let f = this.getEffectiveViewport1(this.cv);
            let g = this.an(this.w4, this.w6.f, this.y1(this.cv), this.y3(this.cv), 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.aa5(this.xl, f);
            l = Math.max(l, 3);
            let m = (l - 1) / 2;
            if (j < k) {
                return this.aay(h, m);
            }
            else {
                return this.aay(i, m);
            }
        }
        gw(a, b) {
            if (this.gz(a, b)) {
                return true;
            }
            return false;
        }
        gz(a, b) {
            let c = this.wm(a);
            if (c.isEmpty) {
                return false;
            }
            let d = RectUtil.r(c, (this.ie / 2) + this.iu(b));
            if (d.containsPoint(a)) {
                let e = this.ap(a);
                if (e != null) {
                    for (let f = 0; f < e.length; f++) {
                        let g = e[f];
                        let h = RectUtil.r(g, (this.ie / 2) + this.iu(b));
                        if (h.containsPoint(a)) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
        q7(a, b, c, d) {
            switch (b) {
                case FinancialPriceSeries.$$p[4]:
                case FinancialPriceSeries.$$p[5]:
                case FinancialPriceSeries.$$p[6]:
                case FinancialPriceSeries.$$p[7]:
                case FinancialPriceSeries.$$p[1]:
                case FinancialPriceSeries.$$p[2]:
                case FinancialPriceSeries.$$p[9]:
                case FinancialPriceSeries.$$p[10]:
                    this.qd();
                    break;
                case FinancialSeries.$$p[14]:
                    this.aa0.cg();
                    if (this.db != null) {
                        this.db.n2();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.aa0.b8 = CategoryTrendLineManagerFactory.a(this.aa0.b8, this.w4, this.st, this, this.dr);
                    }
                    break;
            }
            super.q7(a, b, c, d);
            if (this.aa0.ca && this.aa0.b8 != null && this.aa0.b8.g$b(a, b, c, d)) {
                this.rp(false);
                this.qj();
            }
            switch (b) {
                case FinancialPriceSeries.$$p[3]:
                    if (this.st != null) {
                        this.abz();
                        this.sg();
                        this.w6.x();
                        this.aac(this.w6, this.aa0);
                    }
                    this.qj();
                    break;
                case "ActualHighlightingMode":
                case "ActualSelectionMode":
                case "ActualFocusMode":
                    this.rp(true);
                    break;
                case "TrendLineBrush":
                    this.rd(b);
                    break;
                case "TrendLineType":
                    this.qj();
                    break;
                case FinancialSeries.$$p[10]:
                case FinancialPriceSeries.$$p[8]:
                    this.q1();
                    break;
            }
        }
        abz() {
            this.aa0.ck();
            if (this.cu != null) {
                this.cu.ck();
            }
        }
        ay(a) {
            if (a != null && a == this.xn && this.xz != null && !isNaN_(this.xz.minimum) && this.xy != null && !isNaN_(this.xy.maximum)) {
                return new AxisRange(this.xz.minimum, this.xy.maximum);
            }
            return null;
        }
        az(a) {
            if (a.isEmpty && this.db != null) {
                a = this.db.v4;
            }
            if (this.xz == null || this.xy == null) {
                return null;
            }
            let b = this.wh(this.cv);
            let c = new ScalerParams(0, a, this.db.wj, this.w4.ch, this.getEffectiveViewport());
            let d = (this.w4.eo(b.left, c));
            let e = (this.w4.eo(b.right, c));
            if (this.w4.ch) {
                let f = d;
                d = e;
                e = f;
            }
            let g = null;
            if (this.w4.cn) {
                g = this.w4;
                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.xz.count - 1, d));
            e = Math.max(0, Math.min(this.xz.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.xz.item(k);
                if (this.xz.mayContainUnknowns) {
                    if (isInfinity(l) || isNaN_(l)) {
                        continue;
                    }
                }
                let m = this.xy.item(k);
                if (this.xy.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.ax(n, this.xn, a);
            return n;
        }
        iy() {
            return Series.iz(this.x0, typeCast(ISortingAxis_$type, this.w4));
        }
        gd(a) {
            let b = this.dn != null ? this.dn.indexOf(a) : -1;
            let c = this.cv.by;
            c = c.copy();
            let d = this.cv.bx;
            let e = new Rect(0, 0, 0, 1, 1);
            let f = this.wj(this.cv);
            if (b >= 0 && Rect.l_op_Inequality(c, null) && Rect.l_op_Inequality(d, null)) {
                if (this.w4 != null) {
                    let g = new ScalerParams(0, e, e, this.w4.ch, f);
                    let h = this.w4.el(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.xn != null && this.xz != null && this.xy != null && b < this.xz.count && b < this.xy.count) {
                    let i = new ScalerParams(0, e, e, this.xn.ch, f);
                    i.b = this.iy();
                    let j = this.xn.el(this.xz.item(b), i);
                    let k = this.xn.el(this.xy.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.c3.au(this.db, c, true);
            }
            return b >= 0;
        }
        he(a, b, c) {
            let d = super.he(a, b, c);
            if (this.x0 == null || this.xx == null || this.xy == null || this.xz == null) {
                d = false;
            }
            return d;
        }
        aaa(a, b) {
            super.aaa(a, b);
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = this.w4;
            let g = this.xn;
            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.iy();
                return $ret;
            })());
            let j = this.w4.ag();
            let k = j[0];
            let l = j[1];
            a.f.clear();
            if (a.m != null) {
                a.m.clear();
            }
            a.n.clear();
            a.q.clear();
            let m = 0;
            let n = typeCast(ISortingAxis_$type, this.w4);
            if (n != null && (n.i$b == null || n.i$b.count != this.dn.count)) {
                return;
            }
            m = this.yv(c, d, e);
            let o = typeCast(FinancialPriceSeriesView.$, b);
            let p = this.id;
            let q = b.b0.b;
            if (this.trendLineType != 0) {
                let r = new Array(this.dn.count);
                let s = 0;
                for (let t of fromEnum(this.ym)) {
                    r[s] = t;
                    s++;
                }
                if (this.aa0.ca) {
                    this.aa0.b8.prepareLineCore(a.q, this.trendLineType, boxArray$1(r), this.trendLinePeriod, (u) => this.w4.el(u, h), (u) => this.xn.el(u, 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.i = d;
                        $ret.h = e;
                        $ret.c = k;
                        $ret.b = l;
                        return $ret;
                    })()));
                }
            }
            let u = this.w4.eo(2, h) - this.w4.eo(1, h);
            for (let v = b.b0.c; v <= b.b0.d; ++v) {
                let w;
                let x = v * q;
                if (n == null) {
                    w = b.b0.getBucket(v);
                }
                else {
                    let y = n.i$b._inner[v];
                    x = y;
                    let z = n.i$d(y);
                    let aa = this.x0.item(y);
                    let ab = this.xy.item(y);
                    let ac = this.xz.item(y);
                    let ad = this.xx.item(y);
                    let ae = aa;
                    let af = ab;
                    let ag = ac;
                    let ah = ad;
                    let ai = z;
                    while (v < b.b0.d) {
                        y = n.i$b._inner[v + 1];
                        ai = n.i$d(y);
                        if (ai - z > u * p) {
                            break;
                        }
                        x = y;
                        v++;
                        af = Math.max(af, this.xy.item(y));
                        ag = Math.min(ag, this.xz.item(y));
                        ah = this.xx.item(y);
                    }
                    let aj = NaN;
                    if (!isNaN_(z)) {
                        aj = this.w4.el(z, h);
                    }
                    w = [aj, ae, af, ag, ah];
                }
                if (!isNaN_(w[0])) {
                    if (n != null) {
                        w[0] = w[0] + m;
                    }
                    else {
                        w[0] = f.el(w[0], h) + m;
                    }
                    w[1] = g.el(w[1], i);
                    w[2] = g.el(w[2], i);
                    w[3] = g.el(w[3], i);
                    w[4] = g.el(w[4], i);
                    if (n != null) {
                        if (a.m == null) {
                            a.m = new List$1(Number_$type, 0);
                        }
                        a.m.add(x);
                    }
                    a.f.add(w);
                }
            }
            return;
        }
        o5(a, b) {
            super.o5(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();
            }
        }
        so(a, b) {
            super.so(a, b);
            if (this.db != null) {
                this.db.n2();
            }
        }
        wt(a, b) {
            if (this.w4 != null && this.w4.categoryMode == 0) {
                let c = this.getEffectiveViewport1(this.cv);
                let d = this.aa5(this.xl, c) / 2;
                return new Thickness(1, d, 0, d, 0);
            }
            return super.wt(a, b);
        }
        get_ed() {
            return true;
        }
        aac(a, b) {
            super.aac(a, b);
            if (this.w4 == null || this.xn == null) {
                return;
            }
            let c = false;
            if (b.b3(a)) {
                c = true;
                b.b5(a);
            }
            this.xd.a2(this, this.yc(), runOn(this, this.ww), this.y1(b), this.y3(b));
            let d = false;
            let e = this.xd.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.q);
            }
            if (d) {
                this.abx(a, b, c);
            }
            else {
                f.b9.count = 0;
                this.abw(a, b);
            }
        }
        iw() {
            let a = this.getEffectiveViewport1(this.cv);
            return this.aa5(this.xl, a);
        }
        abx(a, b, c) {
            let d = this.aa1;
            let e = this.getEffectiveViewport1(b);
            let f = this.aa5(b, e);
            let g = (f - 1) / 2;
            let h = typeCast(ISortingAxis_$type, this.w4) !== null;
            let i = typeCast(FinancialPriceSeriesView.$, b);
            i.cb = true;
            let j = a.f;
            let k = 0;
            let l = this.dn.count;
            let m = this.w4;
            let n = new ScalerParams(0, b.by, b.bx, m.ch, e);
            let o = this.u7;
            let p = this.aau;
            if (p == null) {
                p = o;
            }
            let q = this.vb;
            let r = this.ack;
            if (r == null) {
                r = q;
            }
            for (let s = 0; s < j.count; ++s) {
                let t = j._inner[s][0] - g;
                let u = j._inner[s][0];
                let v = j._inner[s][0] + g;
                let w = j._inner[s][1];
                let x = j._inner[s][2];
                let y = j._inner[s][3];
                let z = j._inner[s][4];
                if (isNaN_(w) || isNaN_(x) || isNaN_(y) || isNaN_(z)) {
                    continue;
                }
                let aa = i.b9.item(k);
                k++;
                let ab = w < z;
                let ac = new PathGeometry();
                if (c) {
                    switch (d) {
                        case 0:
                            if (ab) {
                                let ad = w;
                                w = z;
                                z = ad;
                            }
                            let ae = new PathFigure();
                            ae._startPoint = { $type: Point_$type, x: u, y: y };
                            ae._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: w };
                                return $ret;
                            })()));
                            let af = new PathFigure();
                            af._startPoint = { $type: Point_$type, x: t, y: z };
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: v, y: z };
                                return $ret;
                            })()));
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: v, y: w };
                                return $ret;
                            })()));
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: w };
                                return $ret;
                            })()));
                            af._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: t, y: z };
                                return $ret;
                            })()));
                            let ag = new PathFigure();
                            ag._startPoint = { $type: Point_$type, x: u, y: z };
                            ag._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: x };
                                return $ret;
                            })()));
                            ac.c.add(ae);
                            ac.c.add(af);
                            ac.c.add(ag);
                            break;
                        case 1:
                            let ah = new PathFigure();
                            ah._startPoint = { $type: Point_$type, x: t, y: w };
                            ah._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: w };
                                return $ret;
                            })()));
                            let ai = new PathFigure();
                            ai._startPoint = { $type: Point_$type, x: u, y: y };
                            ai._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: u, y: x };
                                return $ret;
                            })()));
                            let aj = new PathFigure();
                            aj._startPoint = { $type: Point_$type, x: u, y: z };
                            aj._segments.add(((() => {
                                let $ret = new LineSegment(1);
                                $ret.c = { $type: Point_$type, x: v, y: z };
                                return $ret;
                            })()));
                            ac.c.add(ah);
                            ac.c.add(ai);
                            ac.c.add(aj);
                            break;
                    }
                }
                if (ab) {
                    this.xd.ak = p;
                    this.xd.ag = p;
                    this.xd.ah = r;
                    this.xd.al = r;
                    this.xd.f = true;
                }
                else {
                    this.xd.ak = o;
                    this.xd.ag = o;
                    this.xd.ah = q;
                    this.xd.al = q;
                    this.xd.f = false;
                }
                let ak = this.xd.aw(l, s)[0];
                if (h && a.m != null && s >= 0 && s < a.m.count) {
                    ak = truncate(Math.round(a.m._inner[s]));
                }
                this.z9(j, s, l, m, n, b.q, ak);
                if (d == 1) {
                    this.xd.ad(aa, true, false, false, false);
                }
                else {
                    this.xd.ad(aa, false, false, false, false);
                }
                if (c) {
                    aa.an = ac;
                }
            }
            i.b9.count = k;
            i.cf();
        }
        aa5(a, b) {
            let c = this.w4.k8(a.by, a.bx, b);
            c = Math.max(c, this.id * 0.9);
            c = Math.max(c, 3);
            return c;
        }
        abw(a, b) {
            let c = this.aa1;
            let d = this.getEffectiveViewport1(b);
            let e = this.aa5(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;
                }
            }
        }
        kx(a, b) {
            if (this.aa0.ca && a == this.aa0.b8.g$j) {
                return null;
            }
            return super.kx(a, b);
        }
        sf() {
            super.sf();
            if (this.index < 0) {
                return;
            }
            this.aa0.cl();
        }
        px(a) {
            super.px(a);
            if (this.aa0.ca) {
                this.bc.exportTrendlineData(this, a, this.aa0.b8.g$j);
            }
        }
        vv() {
            return this.ack;
        }
        r1(a, b) {
            super.r1(a, b);
            this.ack = b;
        }
        be(a) {
            if (this.aa1 == 0) {
                return 3;
            }
            else if (this.aa1 == 1) {
                if (this.bd == 1) {
                    return 3;
                }
                return 2;
            }
            return a;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.i3(c, false, false);
            let e = this.i1(c, false, false);
            let f = new DataLegendSeriesValueInfo();
            f.a = 4;
            f.l = this.yw(c, false, false);
            f.q = "Close";
            f.r = this.y8 != null ? this.y8 : "Close";
            f.s = this.aa9 != null ? this.aa9 : "C:";
            f.t = this.abb != null ? this.abb : "";
            let g = new DataLegendSeriesValueInfo();
            g.l = this.yx(c, false, false);
            g.a = 3;
            g.q = "Open";
            g.r = this.zu != null ? this.zu : "Open";
            g.s = this.abn != null ? this.abn : "O:";
            g.t = this.abp != null ? this.abp : "";
            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.q = "Change";
            h.r = "Change";
            h.s = "";
            h.v = "";
            h.x = "+";
            h.w = "%";
            h.y = "%";
            h.t = 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.z = h.l >= 0 ? this.u7 : this.aau;
            f.z = h.l >= 0 ? this.u7 : this.aau;
            h.z = h.l >= 0 ? this.u7 : this.aau;
            let i = new DataLegendSeriesValueInfo();
            i.l = e > d ? d : e;
            i.a = 1;
            i.q = "Low";
            i.r = this.zq != null ? this.zq : "Low";
            i.s = this.abi != null ? this.abi : "L:";
            i.t = this.abk != null ? this.abk : "";
            i.k = true;
            let j = new DataLegendSeriesValueInfo();
            j.l = e > d ? e : d;
            j.a = 2;
            j.q = "High";
            j.r = this.zl != null ? this.zl : "High";
            j.s = this.abe != null ? this.abe : "H:";
            j.t = this.abg != null ? this.abg : "";
            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.q = "TypicalPrice";
            k.r = "TypicalPrice";
            k.s = "TP:";
            k.t = "";
            k.k = true;
            let l = new DataLegendSeriesValueInfo();
            l.l = this.yy(c, false, false);
            l.a = 8;
            l.q = "Volume";
            l.r = this.zy != null ? this.zy : "Volume";
            l.s = "VOL:";
            l.t = "";
            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.h = this.mc();
            n.e = m;
            return n;
        }
        aby() {
            if (this.aa2) {
                this.aa3 = 0;
                for (let a = 0; a < this.xy.count; a++) {
                    let b = 0;
                    b += this.xy.item(a);
                    b += this.xz.item(a);
                    b += this.xx.item(a);
                    this.aa3 += b / 3;
                }
                this.aa4 = this.aa3 / this.xy.count;
                this.aa2 = false;
            }
        }
        aq(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.xy.maximum;
                    break;
                case 1:
                    b = this.xz.minimum;
                    break;
                case 3:
                    if (this.aa2) {
                        this.aby();
                    }
                    b = this.aa4;
                    break;
            }
            let c = this.xn;
            if (c.cp) {
                return [NaN, b];
            }
            else {
                return [b, NaN];
            }
        }
        wd(a) {
            let b = NaN;
            switch (a) {
                case 2:
                    b = this.xy.maximum;
                    break;
                case 1:
                    b = this.xz.minimum;
                    break;
                case 3:
                    if (this.aa2) {
                        this.aby();
                    }
                    b = this.aa4;
                    break;
            }
            if (isNaN_(b)) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let c = this.xn;
            let d = this.getEffectiveViewport1(this.cv);
            let e = new ScalerParams(0, this.cv.by, this.cv.bx, c.ch, d);
            if (c.cp) {
                e.b = this.iy();
            }
            e.c = d;
            if (c.cp) {
                return { $type: Point_$type, x: NaN, y: c.el(b, e) };
            }
            else {
                return { $type: Point_$type, x: c.el(b, e), y: NaN };
            }
        }
        we(a) {
            let b = this.xn;
            let c = this.getEffectiveViewport1(this.cv);
            let d = new ScalerParams(0, this.cv.by, this.cv.bx, b.ch, c);
            if (b.cp) {
                d.b = this.iy();
            }
            d.c = c;
            if (b.cp) {
                return { $type: Point_$type, x: NaN, y: b.el(a[1], d) };
            }
            else {
                return { $type: Point_$type, x: b.el(a[0], d), y: NaN };
            }
        }
        ak(a, b) {
            let c = new List$1(ChartSelection.$, 0);
            this.p2(a, c, b);
            return c.toArray();
        }
        p2(a, b, c) {
            let d = this.wp(a);
            let e = this.xn;
            let f = this.w4;
            let g = this.wh(this.cv);
            let h, i;
            let j = this.abt(d, f, true, g, h, i);
            h = j.p4;
            i = j.p5;
            if (this.aaz == 0) {
                this.abv(b, h, i, c);
            }
            else {
                let k, l;
                let m = this.abs(d, e, true, g, k, l);
                k = m.p4;
                l = m.p5;
                this.abu(1, b, h, i, k, l, c);
            }
        }
        abt(a, b, c, d, e, f) {
            let g = new ScalerParams(0, a, this.db.wj, this.w4.ch, this.getEffectiveViewport());
            let h = (this.w4.eo(d.left, g));
            let i = (this.w4.eo(d.right, g));
            if (this.w4.ch) {
                let j = h;
                h = i;
                i = j;
            }
            if (this.w4.cn) {
                let k = this.w4;
                h = k.i$f(h);
                i = k.i$f(i);
            }
            else {
                h = Math.floor(h);
                i = Math.ceil(i);
            }
            e = truncate(Math.max(0, Math.min(this.xz.count - 1, h)));
            f = truncate(Math.max(0, Math.min(this.xz.count - 1, i)));
            return {
                p4: e,
                p5: f
            };
        }
        abs(a, b, c, d, e, f) {
            let g = new ScalerParams(0, a, this.db.wj, b.ch, this.getEffectiveViewport());
            let h = c ? (b.ch ? d.top : d.bottom) : (b.ch ? d.left : d.right);
            let i = c ? (b.ch ? d.bottom : d.top) : (b.ch ? d.right : d.left);
            e = b.eo(h, g);
            f = b.eo(i, g);
            return {
                p4: e,
                p5: f
            };
        }
        abr(a, b, c) {
            if (c == 2 || c == 1) {
                a.add(((() => {
                    let $ret = new ChartSelection();
                    $ret.item = this.dn.item(b);
                    return $ret;
                })()));
            }
            else {
                a.add(((() => {
                    let $ret = new ChartSelection();
                    $ret.item = this.dn.item(b);
                    $ret.series = this;
                    return $ret;
                })()));
            }
        }
        abv(a, b, c, d) {
            if (b == -1 || c == -1) {
                return;
            }
            if (d == 7 || d == 6) {
                a.add(((() => {
                    let $ret = new ChartSelection();
                    $ret.series = this;
                    return $ret;
                })()));
                return;
            }
            for (let e = b; e <= c; e++) {
                this.abr(a, e, d);
            }
        }
        abu(a, b, c, d, e, f, g) {
            if (c == -1 || d == -1) {
                return;
            }
            for (let h = c; h <= d; h++) {
                let i = Math.min(this.x0.item(h), this.xz.item(h));
                let j = Math.max(this.xx.item(h), this.xy.item(h));
                let k = Math.min(i, j);
                let l = Math.max(i, j);
                if (k < f && e < l) {
                    if (g == 7 || g == 6) {
                        b.add(((() => {
                            let $ret = new ChartSelection();
                            $ret.series = this;
                            return $ret;
                        })()));
                        return;
                    }
                    this.abr(b, h, g);
                }
            }
        }
    }
    FinancialPriceSeries.$t = markType(FinancialPriceSeries, 'FinancialPriceSeries', FinancialSeries.$, [ITrendLineSeries_$type]);
    FinancialPriceSeries.ab0 = DependencyProperty.i("ActualTrendLineBrush", Brush.$, FinancialPriceSeries.$, new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
    FinancialPriceSeries.$$p = markDep(DependencyProperty, PropertyMetadata, FinancialPriceSeries, 'raisePropertyChanged', ['CategoryCollisionMode:aaz:ab1', [CategoryCollisionMode_$type, enumGetBox(CategoryCollisionMode_$type, 0)], 'CloseMemberAsLegendLabel:aa9:ab2', [2, null], 'CloseMemberAsLegendUnit:abb:ab3', [2, null], 'DisplayType:aa1:ab4', [PriceDisplayType_$type, enumGetBox(PriceDisplayType_$type, 0)], 'HighMemberAsLegendLabel:abe:ab5', [2, null], 'HighMemberAsLegendUnit:abg:ab6', [2, null], 'LowMemberAsLegendLabel:abi:ab7', [2, null], 'LowMemberAsLegendUnit:abk:ab8', [2, null], 'NegativeOutline:ack:ab9', [Brush.$, null], 'OpenMemberAsLegendLabel:abn:aca', [2, null], 'OpenMemberAsLegendUnit:abp:acb', [2, null], 'TrendLineType::ach', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::acg', [1, 1.5], 'TrendLinePeriod::acf', [1, 7], 'TrendLineBrush::acc', [Brush.$, null], 'TrendLineZIndex:aa7:aci', [1, 1001], 'TrendLineDashArray:acl:acd', [DoubleCollection.$], 'TrendLineDashCap:acm:ace', [PenLineCap_$type, 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.aa1 = Defaults.g;
                this.b6.aau = Defaults.ah;
                this.b6.ack = Defaults.ai;
                this.b6.jp = Defaults.l;
                this.b6.vt = this.b6.vb;
            }
        }
        get b8() {
            if (this.b7 == null) {
                this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.a0(), this.e.st, this.e, this.e.dr);
            }
            return this.b7;
        }
        set b8(a) {
            this.b7 = a;
        }
        get ca() {
            return this.b7 != null;
        }
        ck() {
            if (this.b6.aa1 == 1) {
                this.cq._stroke = this.e.u7;
            }
            else {
                this.cq._stroke = this.e.vb;
            }
            if (this.b6.aa1 == 1) {
                this.cp._stroke = this.b2.aau;
            }
            else {
                this.cp._stroke = this.b6.ack;
            }
        }
        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.acj = null;
            if (this.b6.trendLineBrush != null) {
                this.b6.acj = this.b6.trendLineBrush;
            }
            else {
                this.b6.acj = this.b6.u7;
            }
        }
        bd() {
            super.bd();
            this.cq.ad = this.e.ie;
            this.cq.ai = this.e.v0;
            this.cq.aj = this.e.v1;
            if (this.b6.aa1 == 1) {
                this.cq._stroke = this.e.u7;
            }
            else {
                this.cq._stroke = this.e.vb;
                this.cq._fill = this.e.u7;
            }
            this.cp.ad = this.e.ie;
            this.cp.ai = this.e.v0;
            this.cp.aj = this.e.v1;
            if (this.b6.aa1 == 1) {
                this.cp._stroke = this.b2.aau;
            }
            else {
                this.cp._stroke = this.b6.ack;
                this.cp._fill = this.b2.aau;
            }
        }
        be() {
            super.be();
            let a = this.br();
            this.cq.ad = this.e.ie + 3;
            if (this.b6.aa1 == 1) {
                this.cq._stroke = a;
            }
            else {
                this.cq._stroke = a;
                this.cq._fill = a;
            }
            this.cp.ad = this.e.ie + 3;
            if (this.b6.aa1 == 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.ie + 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.acj;
                    c.ai = this.b6.acl;
                    c.aj = this.b6.acm;
                    a.v(c);
                }
            }
            super.a7(a, b);
        }
        an(a) {
            super.an(a);
            if (this.b6.yc()) {
                for (let b = 0; b < this.cc.count; b++) {
                    let c = this.cc._inner[b];
                    if (c._fill == this.b6.aau) {
                        this.e.bc.exportPathData(a, c, "negativePathShape" + b, ["Negative"]);
                    }
                    else {
                        this.e.bc.exportPathData(a, c, "positivePathShape" + b, ["Positive", "Main"]);
                    }
                }
            }
            else {
                this.e.bc.exportPathData(a, this.cq, "positivePathShape", ["Positive", "Main"]);
                this.e.bc.exportPathData(a, this.cp, "negativePathShape", ["Negative"]);
            }
        }
        cf() {
            this.as();
        }
        cg() {
            if (this.ca) {
                this.b7 = CategoryTrendLineManagerFactory.a(this.b7, this.e.a0(), this.e.st, this.e, this.e.dr);
            }
        }
    }
    FinancialPriceSeriesView.$t = markType(FinancialPriceSeriesView, 'FinancialPriceSeriesView', FinancialSeriesView.$);
    return FinancialPriceSeriesView;
})();
