/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { Base, Number_$type, fromEnum, markType } from "igniteui-react-core/ES5/type";
import { Dictionary$2 } from "igniteui-react-core/ES5/Dictionary$2";
import { List$1 } from "igniteui-react-core/ES5/List$1";
/**
 * @hidden
 */
var PolylineBuilder = /** @class */ (function (_super) {
    tslib_1.__extends(PolylineBuilder, _super);
    function PolylineBuilder() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.a = new Dictionary$2(Number_$type, List$1.$.specialize(Number_$type), 0);
        _this.b = new Dictionary$2(Number_$type, List$1.$.specialize(Number_$type), 0);
        return _this;
    }
    PolylineBuilder.prototype.e = function () {
        this.a.clear();
        this.b.clear();
    };
    PolylineBuilder.prototype.c = function () {
        var e_1, _a;
        var a = new List$1(List$1.$.specialize(Number_$type), 0);
        try {
            for (var _b = tslib_1.__values(fromEnum(this.a.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                a.add(b);
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_1) throw e_1.error; }
        }
        return a;
    };
    PolylineBuilder.prototype.d = function (a, b) {
        var c = null;
        var d = null;
        var e = this.b.tryGetValue(a, c);
        c = e.p1;
        var f = this.a.tryGetValue(b, d);
        d = f.p1;
        if (c == null && d == null) {
            var g = new List$1(Number_$type, 0);
            g.add(a);
            g.add(b);
            this.a.addItem(a, g);
            this.b.addItem(b, g);
        }
        if (c == null && d != null) {
            this.a.removeItem(b);
            d.insert(0, a);
            this.a.addItem(a, d);
        }
        if (c != null && d == null) {
            this.b.removeItem(a);
            c.add(b);
            this.b.addItem(b, c);
        }
        if (c != null && d != null) {
            if (c == d) {
                c.add(b);
                this.b.removeItem(a);
            }
            else {
                this.a.removeItem(d._inner[0]);
                this.b.removeItem(d._inner[d.count - 1]);
                this.b.removeItem(c._inner[c.count - 1]);
                c.o(d);
                this.b.addItem(c._inner[c.count - 1], c);
            }
        }
    };
    PolylineBuilder.$t = markType(PolylineBuilder, 'PolylineBuilder');
    return PolylineBuilder;
}(Base));
export { PolylineBuilder };
