/*
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 { Base, Number_$type, fromEnum, markType } from "./type";
import { List$1 } from "./List$1";
import { DataLegendSeriesValueInfo } from "./DataLegendSeriesValueInfo";
import { Dictionary$2 } from "./Dictionary$2";
import { DataLegendSeriesValueType_$type } from "./DataLegendSeriesValueType";
/**
 * @hidden
 */
export let DataLegendSeriesContext = /*@__PURE__*/ (() => {
    class DataLegendSeriesContext extends Base {
        constructor() {
            super();
            this.d = new Dictionary$2(DataLegendSeriesValueType_$type, DataLegendSeriesValueInfo.$, 0);
            this.b = 0;
            this.e = null;
            this.f = new List$1(DataLegendSeriesValueInfo.$, 0);
        }
        c(a) {
            if (this.d.containsKey(a)) {
                return this.d.item(a);
            }
            return null;
        }
        g(a) {
            if (this.d.containsKey(a)) {
                return this.d.item(a).l;
            }
            return NaN;
        }
        k(a, b) {
            let c = null;
            if (!this.d.containsKey(a)) {
                c = new DataLegendSeriesValueInfo();
                c.a = a;
                this.i(c);
            }
            c.l = b;
        }
        l(a, b) {
            let c = b;
            if (this.d.containsKey(a)) {
                this.j(a);
            }
            c.a = a;
            this.i(c);
        }
        j(a) {
            if (this.d.containsKey(a)) {
                let b = this.d.item(a);
                this.f.remove(b);
                this.d.removeItem(a);
            }
        }
        i(a) {
            let b = false;
            if (a.o == -1) {
                b = true;
                a.o = this.h();
            }
            this.d.item(a.a, a);
            this.f.add(a);
            if (!b) {
                this.f.aa((c, d) => c.o - d.o);
            }
        }
        h() {
            let a = -1;
            for (let b = 0; b < this.f.count; b++) {
                a = Math.max(a, this.f._inner[b].o);
            }
            return a + 1;
        }
        get f() {
            return this.e;
        }
        set f(a) {
            this.e = a;
            this.d.clear();
            for (let b = 0; b < this.e.count; b++) {
                this.e._inner[b].o = b;
                this.d.item(this.e._inner[b].a, this.e._inner[b]);
            }
        }
        a() {
            let a = new List$1(Number_$type, 0);
            for (let b of fromEnum(this.f)) {
                a.add(b.l);
            }
            return a.toArray();
        }
    }
    DataLegendSeriesContext.$t = markType(DataLegendSeriesContext, 'DataLegendSeriesContext');
    return DataLegendSeriesContext;
})();
