/*
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 { __extends } from "tslib";
import { Base, String_$type, runOn, Type, markType, BaseError, Number_$type } from "./type";
import { LinkedList$1 } from "./LinkedList$1";
import { Dictionary$2 } from "./Dictionary$2";
import { LinkedListNode$1 } from "./LinkedListNode$1";
import { timeSpanTotalMilliseconds } from "./timespan";
import { dateNow } from "./date";
import { TaskCompletionSource$1 } from "./TaskCompletionSource$1";
import { isInfinity, isNaN_ } from "./number";
import { AnimationKeyFrame } from "./AnimationKeyFrame";
import { List$1 } from "./List$1";
import { UIElementPropertyId_$type } from "./UIElementPropertyId";
import { UIElementPropertyAccessor } from "./UIElementPropertyAccessor";
import { EasingFunctions } from "./EasingFunctions";
import { AnimationKeyFrameProperty } from "./AnimationKeyFrameProperty";
import { BrushUtil } from "./BrushUtil";
import { InterpolationUtil } from "./InterpolationUtil";
import { MatrixTransform } from "./MatrixTransform";
import { TransformMatrixHelpler } from "./TransformMatrixHelpler";
import { UIElementPropertyAccessorFactory } from "./UIElementPropertyAccessorFactory";
import { HashSet$1 } from "./HashSet$1";
/**
 * @hidden
 */
var KeyFrameAnimationTimeline = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(KeyFrameAnimationTimeline, _super);
    function KeyFrameAnimationTimeline(a, b) {
        var _this = _super.call(this) || this;
        _this.c = null;
        _this.a = null;
        _this.h = new Date();
        _this.g = new LinkedList$1(IKeyFrameAnimation_$type);
        _this.f = new Dictionary$2(String_$type, IKeyFrameAnimation_$type, 0);
        _this.e = new Dictionary$2(IKeyFrameAnimation_$type, LinkedListNode$1.$.specialize(IKeyFrameAnimation_$type), 0);
        _this.k = 0;
        _this.d = false;
        _this.i = 0;
        _this.l = -1;
        _this.c = a;
        _this.a = b;
        _this.h = dateNow();
        return _this;
    }
    Object.defineProperty(KeyFrameAnimationTimeline.prototype, "b", {
        get: function () {
            return this.a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationTimeline.prototype, "j", {
        get: function () {
            if (this.d) {
                return this.i;
            }
            return timeSpanTotalMilliseconds((+(dateNow()) - +(this.h)));
        },
        enumerable: false,
        configurable: true
    });
    KeyFrameAnimationTimeline.prototype.m = function (a) {
        if (this.f.containsKey(a.id)) {
            return;
        }
        this.g.f(a);
        var b = this.g.d;
        this.e.addItem(a, b);
        this.f.addItem(a.id, a);
        var c = false;
        if (this.k == 0) {
            c = true;
        }
        this.k++;
        if (c) {
            this.n();
        }
    };
    KeyFrameAnimationTimeline.prototype.o = function (a) {
        if (!this.e.containsKey(a)) {
            return;
        }
        var b = this.e.item(a);
        this.g.h(b);
        this.f.removeItem(a.id);
        this.e.removeItem(a);
        var c = false;
        this.k--;
        if (this.k == 0) {
            c = true;
        }
        if (c) {
            this.p();
        }
    };
    KeyFrameAnimationTimeline.prototype.p = function () {
        if (this.l >= 0) {
            this.c.teardownTicking(this.l);
            this.l = -1;
        }
    };
    KeyFrameAnimationTimeline.prototype.n = function () {
        this.l = this.c.setupTicking(runOn(this, this.q));
        this.c.requestFrame(this.l);
    };
    KeyFrameAnimationTimeline.prototype.q = function () {
        var a = this.j;
        this.i = a;
        try {
            this.d = true;
            var b = this.g.c;
            if (b == null) {
                this.p();
                this.d = false;
                return;
            }
            while (b != null) {
                var c = b.c;
                if (c.playState == 1) {
                    c.aq();
                }
                else {
                    c.aq();
                    this.o(b.c);
                }
                b = b.a;
            }
            this.c.requestFrame(this.l);
        }
        finally {
            this.d = false;
        }
    };
    KeyFrameAnimationTimeline.$t = markType(KeyFrameAnimationTimeline, 'KeyFrameAnimationTimeline');
    return KeyFrameAnimationTimeline;
}(Base));
export { KeyFrameAnimationTimeline };
/**
 * @hidden
 */
export var IKeyFrameAnimation_$type = new Type(null, 'IKeyFrameAnimation');
/**
 * @hidden
 */
var KeyFrameAnimationDirect = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(KeyFrameAnimationDirect, _super);
    function KeyFrameAnimationDirect(a, b) {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.m = NaN;
        _this.d = false;
        _this.p = NaN;
        _this.i = false;
        _this.u = null;
        _this.n = NaN;
        _this.g = false;
        _this.o = 1;
        _this.q = NaN;
        _this.j = false;
        _this.b = null;
        _this.onFinished = null;
        _this.onCanceled = null;
        _this.h = false;
        _this.f = false;
        _this.e = false;
        _this.w = null;
        _this.v = null;
        _this.u = "AUTO_ID_" + KeyFrameAnimationDirect.t.toString();
        KeyFrameAnimationDirect.t++;
        _this.effect = a;
        _this.effect.r = _this;
        _this.b = b;
        return _this;
    }
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "effect", {
        get: function () {
            return this.a;
        },
        set: function (a) {
            this.a = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "l", {
        get: function () {
            if (this.d) {
                return true;
            }
            if (this.j) {
                return true;
            }
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "currentTime", {
        get: function () {
            if (this.d) {
                return this.m;
            }
            return (this.c.j - this.startTime) * this.playbackRate;
        },
        set: function (a) {
            this.ar(a);
            this.as(true, false);
        },
        enumerable: false,
        configurable: true
    });
    KeyFrameAnimationDirect.prototype.as = function (a, b) {
        var _this = this;
        var c;
        var d = false;
        if (!a) {
            var e = this.d;
            this.d = false;
            c = this.currentTime;
            d = this.l;
            this.d = e;
        }
        else {
            c = this.currentTime;
            d = this.l;
        }
        if (d && this.j && !this.f && !this.h) {
            if (this.playbackRate > 0 && c >= this.r) {
                if (a) {
                    this.m = c;
                    this.d = true;
                }
                else {
                    if (this.i) {
                        this.m = Math.max(this.p, this.r);
                    }
                    else {
                        this.m = this.r;
                    }
                }
            }
            else if (this.playbackRate < 0 && c <= 0) {
                if (a) {
                    this.m = c;
                }
                else {
                    if (this.i) {
                        this.m = Math.min(this.p, 0);
                    }
                    else {
                        this.m = 0;
                    }
                }
            }
            if (this.playbackRate != 0) {
                if (a && this.d) {
                    this.q = this.c.j - (this.m / this.playbackRate);
                    this.j = true;
                    this.d = false;
                }
            }
        }
        this.p = this.currentTime;
        this.i = true;
        var f = this.playState == 3;
        if (!b && f && !this.k()) {
            this.an(function () { return _this.ad(); });
        }
        if (f && !this.k()) {
            if (b) {
                this.aa();
                this.ad();
            }
        }
        if (!f && this.k()) {
            this.v = this.x();
        }
    };
    KeyFrameAnimationDirect.prototype.x = function () {
        return new TaskCompletionSource$1(IKeyFrameAnimation_$type, 0);
    };
    KeyFrameAnimationDirect.prototype.aa = function () {
        this.e = false;
    };
    KeyFrameAnimationDirect.prototype.ad = function () {
        if (!this.e) {
            return;
        }
        this.e = false;
        if (this.playState != 3) {
            return;
        }
        this.al(this);
        this.ah();
    };
    KeyFrameAnimationDirect.prototype.ah = function () {
    };
    KeyFrameAnimationDirect.prototype.al = function (a) {
        this.v.e(a);
    };
    KeyFrameAnimationDirect.prototype.an = function (a) {
        if (!this.e) {
            this.e = true;
            this.c.b.enqueueAction(function () { return a(); });
        }
    };
    KeyFrameAnimationDirect.prototype.k = function () {
        return this.v == null || this.v.b.c;
    };
    KeyFrameAnimationDirect.prototype.ar = function (a) {
        if (this.d || !this.j || this.playbackRate == 0) {
            this.m = a;
            this.d = true;
        }
        else {
            this.q = this.c.j - (a / this.playbackRate);
        }
    };
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "finished", {
        get: function () {
            return this.v.b;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "ready", {
        get: function () {
            return this.w.b;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "id", {
        get: function () {
            return this.u;
        },
        set: function (a) {
            this.u = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "r", {
        get: function () {
            return this.effect != null ? this.effect.as : 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "playState", {
        get: function () {
            if (!this.l && !this.f && !this.h) {
                return 0;
            }
            else if (this.f || (!this.j && !this.h)) {
                return 2;
            }
            else if (this.l && (this.s > 0 && this.currentTime >= this.r || this.s < 0 && this.currentTime <= 0)) {
                return 3;
            }
            return 1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "s", {
        get: function () {
            if (this.g) {
                return this.n;
            }
            return this.o;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "playbackRate", {
        get: function () {
            return this.o;
        },
        set: function (a) {
            this.o = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "startTime", {
        get: function () {
            return this.q;
        },
        set: function (a) {
            var b = this.c.j;
            var c = this.p;
            this.q = a;
            this.j = true;
            if (this.playbackRate != 0) {
                this.d = false;
            }
            this.as(true, false);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(KeyFrameAnimationDirect.prototype, "c", {
        get: function () {
            return this.b;
        },
        enumerable: false,
        configurable: true
    });
    KeyFrameAnimationDirect.prototype.cancel = function () {
        if (this.playState != 0) {
            this.ak();
            this.ai("AbortError");
            this.v = this.x();
            this.ag();
            this.d = false;
            this.j = false;
        }
    };
    KeyFrameAnimationDirect.prototype.ai = function (a) {
        if (this.v != null) {
            this.v.d(new BaseError(1, a));
        }
    };
    KeyFrameAnimationDirect.prototype.aj = function (a) {
        if (this.w != null) {
            this.w.d(new BaseError(1, a));
        }
    };
    KeyFrameAnimationDirect.prototype.ag = function () {
    };
    KeyFrameAnimationDirect.prototype.ak = function () {
        if (this.h) {
            this.h = false;
        }
        if (this.f) {
            this.f = false;
        }
        this.z();
        this.aj("AbortError");
    };
    KeyFrameAnimationDirect.prototype.finish = function () {
        if (this.s == 0 || (this.s > 0 && isInfinity(this.r))) {
            return;
        }
        this.z();
        var a;
        if (this.playbackRate > 0) {
            a = this.r;
        }
        else {
            a = 0;
        }
        this.ar(a);
        if (!this.j) {
            this.q = this.c.j - (a / this.playbackRate);
            this.j = true;
        }
        if (this.f && this.j) {
            this.d = false;
            this.ab();
            this.am(this);
        }
        if (this.h && this.j) {
            this.ac();
            this.am(this);
        }
        this.as(true, true);
    };
    KeyFrameAnimationDirect.prototype.pause = function () {
        this.ae();
    };
    KeyFrameAnimationDirect.prototype.ae = function () {
        var _this = this;
        if (this.f) {
            return;
        }
        if (this.playState == 2) {
            return;
        }
        if (!this.l) {
            if (this.playbackRate >= 0) {
                this.d = true;
                this.m = 0;
            }
            if (isInfinity(this.r)) {
                return;
            }
            this.m = this.r;
            this.d = true;
        }
        var a = false;
        if (this.h) {
            a = true;
        }
        if (!a) {
            this.w = this.y();
        }
        this.ao(function () {
            if (!_this.f) {
                return;
            }
            _this.f = false;
            var b = _this.c.j;
            if (_this.j && !_this.d) {
                _this.m = (b - _this.q) * _this.playbackRate;
            }
            _this.z();
            _this.j = false;
            _this.am(_this);
            _this.as(false, false);
        });
        this.as(false, false);
    };
    KeyFrameAnimationDirect.prototype.y = function () {
        return new TaskCompletionSource$1(IKeyFrameAnimation_$type, 0);
    };
    KeyFrameAnimationDirect.prototype.ao = function (a) {
        if (!this.f) {
            this.f = true;
            this.c.b.enqueueAction(function () { return a(); });
        }
    };
    KeyFrameAnimationDirect.prototype.play = function () {
        this.af(true);
    };
    KeyFrameAnimationDirect.prototype.af = function (a) {
        var _this = this;
        var b = this.f;
        if (this.s > 0 && a && (!this.l || this.currentTime < 0 || this.currentTime >= this.r)) {
            this.m = 0;
            this.d = true;
        }
        else if (this.s < 0 && a && (!this.l || this.currentTime <= 0 || this.currentTime > this.r)) {
            if (isInfinity(this.r)) {
                return;
            }
            this.m = this.r;
            this.d = true;
        }
        else if (this.s == 0 && !this.l) {
            this.m = 0;
            this.d = true;
        }
        var c = false;
        if (this.f) {
            this.ab();
            c = true;
        }
        if (this.h) {
            this.ac();
            c = true;
        }
        if (!this.d && !b && !this.g) {
            return;
        }
        if (this.d) {
            this.j = false;
        }
        if (!c) {
            this.w = this.y();
        }
        this.ap(function () {
            if (!_this.h) {
                return;
            }
            _this.h = false;
            if (!_this.j && !_this.d) {
                return;
            }
            var d = _this.c.j;
            if (_this.d) {
                _this.z();
                var e = d;
                if (_this.playbackRate != 0) {
                    e = d - _this.m / _this.playbackRate;
                }
                _this.q = e;
                _this.j = true;
                if (_this.playbackRate != 0) {
                    _this.d = false;
                }
            }
            else if (_this.j && _this.g) {
                var f = (d - _this.q) * _this.playbackRate;
                _this.z();
                if (_this.playbackRate == 0) {
                    _this.m = f;
                    _this.d = true;
                }
                var g = d;
                if (_this.playbackRate != 0) {
                    g = d - f / _this.playbackRate;
                }
                _this.q = g;
                _this.j = true;
            }
            _this.am(_this);
            _this.as(false, false);
            _this.c.m(_this);
        });
        this.as(false, false);
    };
    KeyFrameAnimationDirect.prototype.am = function (a) {
        if (this.w != null) {
            this.w.e(a);
        }
    };
    KeyFrameAnimationDirect.prototype.ab = function () {
        this.f = false;
    };
    KeyFrameAnimationDirect.prototype.ac = function () {
        this.h = false;
    };
    KeyFrameAnimationDirect.prototype.ap = function (a) {
        if (!this.h) {
            this.h = true;
            this.c.b.enqueueAction(function () { return a(); });
        }
    };
    KeyFrameAnimationDirect.prototype.reverse = function () {
        var a = this.n;
        this.n = -this.s;
        this.g = true;
        this.af(true);
    };
    KeyFrameAnimationDirect.prototype.updatePlaybackRate = function (a) {
        var b = this.playState;
        this.n = a;
        this.g = true;
        if (b == 0 || b == 2) {
            this.z();
        }
        else if (b == 3) {
            var c = this.d;
            this.d = false;
            var d = this.currentTime;
            this.d = c;
            if (this.n == 0) {
                this.q = this.c.j;
            }
            else {
                this.q = this.c.j - (d / this.n);
            }
            this.z();
        }
        else {
            this.af(false);
        }
    };
    KeyFrameAnimationDirect.prototype.z = function () {
        if (this.g) {
            this.o = this.n;
            this.g = false;
        }
    };
    KeyFrameAnimationDirect.prototype.commitStyles = function () {
        this.effect.a6();
    };
    KeyFrameAnimationDirect.prototype.aq = function () {
        this.effect.a7();
        this.as(false, false);
    };
    KeyFrameAnimationDirect.$t = markType(KeyFrameAnimationDirect, 'KeyFrameAnimationDirect', Base.$, [IKeyFrameAnimation_$type]);
    KeyFrameAnimationDirect.t = 0;
    return KeyFrameAnimationDirect;
}(Base));
export { KeyFrameAnimationDirect };
/**
 * @hidden
 */
var AnimationKeyFrameEffect = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnimationKeyFrameEffect, _super);
    function AnimationKeyFrameEffect(a) {
        var _rest = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            _rest[_i - 1] = arguments[_i];
        }
        var _this = _super.call(this) || this;
        _this.r = null;
        _this.a4 = null;
        _this.o = 0;
        _this.q = null;
        _this.ag = new List$1(AnimationKeyFrame.$, 0);
        _this.c = null;
        _this.al = 0;
        _this.ah = 0;
        _this.az = null;
        _this.t = 0;
        _this.ai = 0;
        _this.aj = 0;
        _this.v = 0;
        _this.ak = 0;
        _this.u = 0;
        _this.d = null;
        _this.a = null;
        _this.b = null;
        _this.p = null;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    _this.a4 = c;
                    _this.o = d;
                    _this.p = f;
                    _this.a8();
                    _this.q = e;
                }
                break;
            case 1:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    var g = _rest[4];
                    _this.a4 = c;
                    _this.o = d;
                    _this.q = e;
                    _this.p = f;
                    _this.a8();
                    _this.ag.o(g);
                }
                break;
        }
        return _this;
    }
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "an", {
        get: function () {
            return this.aj * this.ai;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "as", {
        get: function () {
            return Math.max(this.al + this.an + this.ah, 0);
        },
        enumerable: false,
        configurable: true
    });
    AnimationKeyFrameEffect.prototype.a8 = function () {
        this.al = this.p.f;
        this.ah = this.p.h;
        this.t = this.p.a;
        this.ai = this.p.i;
        this.aj = this.p.g;
        this.v = this.p.c;
        this.ak = this.p.j;
        this.u = this.p.b;
        this.az = this.a0(this.u);
    };
    AnimationKeyFrameEffect.prototype.a0 = function (a) {
        switch (a) {
            case 3: return function (b) { return b; };
            case 1: return EasingFunctions.exponentialEase;
            case 2: return EasingFunctions.circleEase;
            case 0: return EasingFunctions.cubicEase;
        }
        return function (b) { return b; };
    };
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "k", {
        get: function () {
            if (this.d == null) {
                this.d = this.e();
            }
            return this.d;
        },
        enumerable: false,
        configurable: true
    });
    AnimationKeyFrameEffect.prototype.e = function () {
        var a = this.h;
        if (a.length <= 1) {
            return [0];
        }
        var b = new Array(a.length);
        var c = 1 / (a.length - 1);
        var d = 0;
        for (var e = 0; e < a.length; e++) {
            if (isNaN_(a[e].j)) {
                b[e] = d;
            }
            else {
                b[e] = a[e].j;
                d = a[e].j;
                if (((a.length - 1) - e) > 0) {
                    c = (1 - d) / ((a.length - 1) - e);
                }
            }
            d += c;
        }
        return b;
    };
    AnimationKeyFrameEffect.prototype.l = function (a) {
        this.ag.add(a);
        this.c = null;
        this.a = null;
        return this;
    };
    AnimationKeyFrameEffect.prototype.m = function () {
        var a = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            a[_i] = arguments[_i];
        }
        var b = new AnimationKeyFrame(0);
        if (a != null) {
            for (var c = 0; c < a.length; c++) {
                b.c(a[c]);
            }
        }
        this.l(b);
        return this;
    };
    AnimationKeyFrameEffect.prototype.n = function (a) {
        var b = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            b[_i - 1] = arguments[_i];
        }
        var c = new AnimationKeyFrame(1, a);
        if (b != null) {
            for (var d = 0; d < b.length; d++) {
                c.c(b[d]);
            }
        }
        this.l(c);
        return this;
    };
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "au", {
        get: function () {
            if (this.r != null) {
                return this.r.currentTime;
            }
            return NaN;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "ac", {
        get: function () {
            if (this.r != null) {
                return this.r.l;
            }
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "ap", {
        get: function () {
            return Math.max(Math.min(this.al, this.as), 0);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "am", {
        get: function () {
            return Math.max(Math.min(this.al + this.an, this.as), 0);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "w", {
        get: function () {
            if (this.r != null && this.r.playbackRate < 0) {
                return false;
            }
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "s", {
        get: function () {
            if (this.ac && (this.au < this.ap || !this.w && this.au == this.ap)) {
                return 0;
            }
            if (this.ac && (this.au > this.am || this.w && this.au == this.am)) {
                return 2;
            }
            if (this.ac) {
                return 1;
            }
            return 3;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "ao", {
        get: function () {
            var a = this.s;
            switch (a) {
                case 0: if (this.t == 3 || this.t == 4) {
                    return Math.max(this.au - this.al, 0);
                }
                else {
                    return NaN;
                }
                case 1: return this.au - this.al;
                case 2: if (this.t == 2 || this.t == 4) {
                    return Math.max(Math.min(this.au - this.al, this.an), 0);
                }
                else {
                    return NaN;
                }
                default: return NaN;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "y", {
        get: function () {
            if (!this.ac) {
                return false;
            }
            var a = this.s;
            switch (a) {
                case 0: if (this.t == 3 || this.t == 4) {
                    return true;
                }
                else {
                    return false;
                }
                case 1: return true;
                case 2: if (this.t == 2 || this.t == 4) {
                    return true;
                }
                else {
                    return false;
                }
                default: return false;
            }
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "ad", {
        get: function () {
            if (!this.y) {
                return false;
            }
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "av", {
        get: function () {
            if (!this.y) {
                return NaN;
            }
            var a = 0;
            if (this.aj == 0) {
                if (this.s == 0) {
                    a = 0;
                }
                else {
                    a = this.ai;
                }
            }
            else {
                a = this.ao / this.aj;
            }
            return a + this.ak;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "ae", {
        get: function () {
            if (!this.ad) {
                return false;
            }
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "aw", {
        get: function () {
            if (!this.ad) {
                return NaN;
            }
            var a = 1;
            if (isInfinity(this.av)) {
                a = this.ak % 1;
            }
            else {
                a = this.av % 1;
            }
            if (a == 0 && (this.s == 1 || this.s == 2) && this.ao == this.an && this.ai != 0) {
                a = 1;
            }
            return a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "z", {
        get: function () {
            if (!this.y) {
                return false;
            }
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "aq", {
        get: function () {
            if (!this.y) {
                return NaN;
            }
            if (this.s == 2 && isInfinity(this.ai)) {
                return Number.POSITIVE_INFINITY;
            }
            if (this.aw == 1) {
                return Math.floor(this.av) - 1;
            }
            return Math.floor(this.av);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "aa", {
        get: function () {
            return this.ae;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "ar", {
        get: function () {
            if (!this.ae) {
                return NaN;
            }
            var a = this.x();
            if (a) {
                return this.aw;
            }
            else {
                return 1 - this.aw;
            }
        },
        enumerable: false,
        configurable: true
    });
    AnimationKeyFrameEffect.prototype.x = function () {
        var a = true;
        if (this.v == 0) {
            a = true;
        }
        else if (this.v == 1) {
            a = false;
        }
        else {
            var b = this.aq;
            if (this.v == 3) {
                b++;
            }
            if (isInfinity(b)) {
                a = true;
            }
            else {
                if (b % 2 == 0) {
                    a = true;
                }
                else {
                    a = false;
                }
            }
        }
        return a;
    };
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "af", {
        get: function () {
            return this.aa;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "ay", {
        get: function () {
            if (!this.aa) {
                return NaN;
            }
            var a = false;
            var b = this.x();
            if (b && this.s == 0) {
                a = true;
            }
            if (!b && this.s == 2) {
                a = true;
            }
            return this.ax(this.ar, a);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "at", {
        get: function () {
            return this.ay;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "ab", {
        get: function () {
            return this.af;
        },
        enumerable: false,
        configurable: true
    });
    AnimationKeyFrameEffect.prototype.ax = function (a, b) {
        return this.az(a);
    };
    AnimationKeyFrameEffect.prototype.a7 = function () {
        if (!this.af) {
            return;
        }
        var a = this.ay;
        for (var b = 0; b < this.f.length; b++) {
            var c = this.a1(this.f[b], this.g[b]);
            this.a5(this.f[b], this.g[b], c);
        }
    };
    AnimationKeyFrameEffect.prototype.a5 = function (a, b, c) {
        b.c(this.a4, c);
    };
    AnimationKeyFrameEffect.prototype.a1 = function (a, b) {
        if (!this.ab) {
            return null;
        }
        var c = a;
        var d = this.at;
        if (this.a4 == null) {
            return null;
        }
        var e = this.a2(c, b);
        var f = new List$1(AnimationKeyFrame.$, 0);
        var g = new List$1(Number_$type, 0);
        for (var h = 0; h < this.h.length; h++) {
            for (var i = 0; i < this.h[h].b.length; i++) {
                if (this.h[h].b[i].a == c) {
                    f.add(this.h[h]);
                    g.add(this.k[h]);
                }
            }
        }
        if (f.count == 0) {
            return e;
        }
        if (g._inner[0] != 0) {
            f.insert(0, new AnimationKeyFrame(1, 0).c(new AnimationKeyFrameProperty(c, e)));
            g.insert(0, 0);
        }
        if (g._inner[f.count - 1] != 1) {
            f.add(new AnimationKeyFrame(1, 1).c(new AnimationKeyFrameProperty(c, e)));
            g.add(1);
        }
        var j = false;
        var k = new List$1(AnimationKeyFrame.$, 0);
        var l = new List$1(Number_$type, 0);
        if (d < 0) {
            var m = 0;
            for (var n = 0; n < f.count; n++) {
                if (g._inner[n] == 0) {
                    m++;
                }
                else {
                    break;
                }
            }
            if (m > 1) {
                j = true;
                k.add(f._inner[0]);
                l.add(g._inner[0]);
            }
        }
        if (d >= 1) {
            var o = 0;
            for (var p = f.count - 1; p >= 0; p--) {
                if (g._inner[p] == 1) {
                    o++;
                }
                else {
                    break;
                }
            }
            if (o > 1) {
                j = true;
                k.add(f._inner[f.count - 1]);
                l.add(g._inner[f.count - 1]);
            }
        }
        if (!j) {
            var q = null;
            var r = -1;
            for (var s = 0; s < f.count; s++) {
                if (g._inner[s] <= d) {
                    q = f._inner[s];
                    r = s;
                }
                else {
                    break;
                }
            }
            if (r == -1) {
                for (var t = 0; t < f.count; t++) {
                    if (g._inner[t] == 0) {
                        q = f._inner[t];
                        r = t;
                    }
                    else {
                        break;
                    }
                }
            }
            k.add(q);
            l.add(g._inner[r]);
            if (r < g.count - 1) {
                k.add(f._inner[r + 1]);
                l.add(g._inner[r + 1]);
            }
        }
        if (k.count == 1) {
            for (var u = 0; u < k._inner[0].b.length; u++) {
                if (k._inner[0].b[u].a == c) {
                    return k._inner[0].b[u].d;
                }
            }
            return null;
        }
        var v = l._inner[0];
        var w = l._inner[k.count - 1];
        var x = k._inner[0].g(c).d;
        var y = k._inner[1].g(c).d;
        var z = (d - v) / (w - v);
        return this.a3(c, z, x, y);
    };
    AnimationKeyFrameEffect.prototype.a3 = function (a, b, c, d) {
        switch (a) {
            case 2:
            case 3:
            case 7:
            case 15:
            case 16: return BrushUtil.k(c, b, d, 0);
            case 4:
            case 13:
            case 6: return InterpolationUtil.f(b, c, d);
            case 11:
            case 10:
            case 12:
            case 8:
            case 9:
            case 17:
            case 19:
            case 22:
            case 23: return c + b * (d - c);
            case 1: return c + b * (d - c);
            case 5: return InterpolationUtil.d(b, c, d);
            case 14: return this.a9(b, c, d);
            case 18: return InterpolationUtil.a(b, c, d);
            default: if (b < 0.5) {
                return c;
            }
            else {
                return d;
            }
        }
        return null;
    };
    AnimationKeyFrameEffect.prototype.a9 = function (a, b, c) {
        var d = TransformMatrixHelpler.d(a, b.j, c.j);
        var e = new MatrixTransform();
        e.j = d;
        return e;
    };
    AnimationKeyFrameEffect.prototype.a2 = function (a, b) {
        return b.b(this.a4);
    };
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "h", {
        get: function () {
            if (this.c == null) {
                this.c = this.ag.toArray();
                this.a = this.i();
                this.b = this.j();
            }
            return this.c;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "f", {
        get: function () {
            if (this.c == null) {
                this.c = this.ag.toArray();
                this.a = this.i();
                this.b = this.j();
            }
            return this.a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnimationKeyFrameEffect.prototype, "g", {
        get: function () {
            if (this.c == null) {
                this.c = this.ag.toArray();
                this.a = this.i();
                this.b = this.j();
            }
            return this.b;
        },
        enumerable: false,
        configurable: true
    });
    AnimationKeyFrameEffect.prototype.j = function () {
        var a = new List$1(UIElementPropertyAccessor.$, 0);
        for (var b = 0; b < this.f.length; b++) {
            a.add(UIElementPropertyAccessorFactory.c.a(this.f[b], this.o));
        }
        return a.toArray();
    };
    AnimationKeyFrameEffect.prototype.i = function () {
        var a = new List$1(UIElementPropertyId_$type, 0);
        var b = new HashSet$1(UIElementPropertyId_$type, 0);
        for (var c = 0; c < this.h.length; c++) {
            for (var d = 0; d < this.h[c].b.length; d++) {
                if (!b.contains(this.h[c].b[d].a)) {
                    b.add_1(this.h[c].b[d].a);
                    a.add(this.h[c].b[d].a);
                }
            }
        }
        return a.toArray();
    };
    AnimationKeyFrameEffect.prototype.a6 = function () {
        var a = this.t;
        this.t = 4;
        this.a7();
        this.t = a;
    };
    AnimationKeyFrameEffect.$t = markType(AnimationKeyFrameEffect, 'AnimationKeyFrameEffect');
    return AnimationKeyFrameEffect;
}(Base));
export { AnimationKeyFrameEffect };
