/*
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, markType } from "igniteui-angular-core";
import { dateMaxValue, dateMinValue, dateAddYears, dateFromValues, dateAddMonths, dateFromTicks } from "igniteui-angular-core";
import { stringIsNullOrWhiteSpace } from "igniteui-angular-core";
/**
 * @hidden
 */
var FinancialChartRangeSelectorViewModel = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(FinancialChartRangeSelectorViewModel, _super);
    function FinancialChartRangeSelectorViewModel() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.b = null;
        _this._notifyChanged = null;
        _this._options = null;
        _this.u = dateMaxValue();
        _this.t = dateMinValue();
        _this._oneMonthChecked = false;
        _this._threeMonthsChecked = false;
        _this._sixMonthsChecked = false;
        _this._yearToDateChecked = false;
        _this._oneYearChecked = false;
        _this._allChecked = false;
        _this._oneMonthVisible = false;
        _this._threeMonthsVisible = false;
        _this._sixMonthsVisible = false;
        _this._yearToDateVisible = false;
        _this._oneYearVisible = false;
        _this._allVisible = false;
        _this.s = dateMinValue();
        _this.r = dateMaxValue();
        _this._onRangeChanged = null;
        return _this;
    }
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "notifyChanged", {
        get: function () {
            return this._notifyChanged;
        },
        set: function (a) {
            this._notifyChanged = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "options", {
        get: function () {
            return this._options;
        },
        set: function (a) {
            this._options = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "selectionStart", {
        get: function () {
            return this.u;
        },
        set: function (a) {
            this.u = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "selectionEnd", {
        get: function () {
            return this.t;
        },
        set: function (a) {
            this.t = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneMonthChecked", {
        get: function () {
            return this._oneMonthChecked;
        },
        set: function (a) {
            this._oneMonthChecked = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "threeMonthsChecked", {
        get: function () {
            return this._threeMonthsChecked;
        },
        set: function (a) {
            this._threeMonthsChecked = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "sixMonthsChecked", {
        get: function () {
            return this._sixMonthsChecked;
        },
        set: function (a) {
            this._sixMonthsChecked = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "yearToDateChecked", {
        get: function () {
            return this._yearToDateChecked;
        },
        set: function (a) {
            this._yearToDateChecked = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneYearChecked", {
        get: function () {
            return this._oneYearChecked;
        },
        set: function (a) {
            this._oneYearChecked = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "allChecked", {
        get: function () {
            return this._allChecked;
        },
        set: function (a) {
            this._allChecked = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneMonthVisible", {
        get: function () {
            return this._oneMonthVisible;
        },
        set: function (a) {
            this._oneMonthVisible = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "threeMonthsVisible", {
        get: function () {
            return this._threeMonthsVisible;
        },
        set: function (a) {
            this._threeMonthsVisible = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "sixMonthsVisible", {
        get: function () {
            return this._sixMonthsVisible;
        },
        set: function (a) {
            this._sixMonthsVisible = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "yearToDateVisible", {
        get: function () {
            return this._yearToDateVisible;
        },
        set: function (a) {
            this._yearToDateVisible = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneYearVisible", {
        get: function () {
            return this._oneYearVisible;
        },
        set: function (a) {
            this._oneYearVisible = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "allVisible", {
        get: function () {
            return this._allVisible;
        },
        set: function (a) {
            this._allVisible = a;
        },
        enumerable: false,
        configurable: true
    });
    FinancialChartRangeSelectorViewModel.prototype.ao = function () {
        if (this.options == null) {
            return;
        }
        this.oneMonthVisible = this.options.contains(0);
        this.threeMonthsVisible = this.options.contains(1);
        this.sixMonthsVisible = this.options.contains(2);
        this.yearToDateVisible = this.options.contains(3);
        this.oneYearVisible = this.options.contains(4);
        this.allVisible = this.options.contains(5);
    };
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "financialChart_RangeSelector_OneMonth", {
        get: function () {
            return !stringIsNullOrWhiteSpace(this.b.bq) ? this.b.bq : "1M";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "financialChart_RangeSelector_ThreeMonths", {
        get: function () {
            return !stringIsNullOrWhiteSpace(this.b.bt) ? this.b.bt : "3M";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "financialChart_RangeSelector_SixMonths", {
        get: function () {
            return !stringIsNullOrWhiteSpace(this.b.bs) ? this.b.bs : "6M";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "financialChart_RangeSelector_YearToDate", {
        get: function () {
            return !stringIsNullOrWhiteSpace(this.b.bv) ? this.b.bv : "YTD";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "financialChart_RangeSelector_OneYear", {
        get: function () {
            return !stringIsNullOrWhiteSpace(this.b.br) ? this.b.br : "1Y";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "financialChart_RangeSelector_All", {
        get: function () {
            return !stringIsNullOrWhiteSpace(this.b.bo) ? this.b.bo : "ALL";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "financialChart_RangeSelector_From", {
        get: function () {
            return !stringIsNullOrWhiteSpace(this.b.bp) ? this.b.bp : "From";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "financialChart_RangeSelector_To", {
        get: function () {
            return !stringIsNullOrWhiteSpace(this.b.bu) ? this.b.bu : "To";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "rangeStart", {
        get: function () {
            return this.s;
        },
        set: function (a) {
            this.s = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "rangeEnd", {
        get: function () {
            return this.r;
        },
        set: function (a) {
            this.r = a;
        },
        enumerable: false,
        configurable: true
    });
    FinancialChartRangeSelectorViewModel.prototype.onPropertiesChanged = function () {
        var a = false;
        var b = +(this.selectionEnd) == +(this.rangeEnd);
        if (this.allChecked != ((+(this.selectionStart) == +(this.rangeStart)) && b)) {
            this.allChecked = (+(this.selectionStart) == +(this.rangeStart)) && b;
            a = true;
        }
        if (this.oneYearChecked != ((+(this.selectionStart) == +(this.oneYearFromEnd)) && b)) {
            this.oneYearChecked = (+(this.selectionStart) == +(this.oneYearFromEnd)) && b;
            a = true;
        }
        if (this.yearToDateChecked != ((+(this.selectionStart) == +(this.firstDayOfEndYear)) && b)) {
            this.yearToDateChecked = (+(this.selectionStart) == +(this.firstDayOfEndYear)) && b;
            a = true;
        }
        if (this.sixMonthsChecked != ((+(this.selectionStart) == +(this.sixMonthsFromEnd)) && b)) {
            this.sixMonthsChecked = (+(this.selectionStart) == +(this.sixMonthsFromEnd)) && b;
            a = true;
        }
        if (this.threeMonthsChecked != ((+(this.selectionStart) == +(this.threeMonthsFromEnd)) && b)) {
            this.threeMonthsChecked = (+(this.selectionStart) == +(this.threeMonthsFromEnd)) && b;
            a = true;
        }
        if (this.oneMonthChecked != ((+(this.selectionStart) == +(this.oneMonthFromEnd)) && b)) {
            this.oneMonthChecked = (+(this.selectionStart) == +(this.oneMonthFromEnd)) && b;
            a = true;
        }
        if (a) {
            if (this.notifyChanged != null) {
                this.notifyChanged();
            }
        }
        return a;
    };
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneYearFromEnd", {
        get: function () {
            return dateAddYears(this.rangeEnd, -1);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "firstDayOfEndYear", {
        get: function () {
            return dateFromValues(this.rangeEnd.getFullYear(), 1, 1, 0, 0, 0, 0);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "sixMonthsFromEnd", {
        get: function () {
            return dateAddMonths(this.rangeEnd, -6);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "threeMonthsFromEnd", {
        get: function () {
            return dateAddMonths(this.rangeEnd, -3);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "oneMonthFromEnd", {
        get: function () {
            return dateAddMonths(this.rangeEnd, -1);
        },
        enumerable: false,
        configurable: true
    });
    FinancialChartRangeSelectorViewModel.prototype.changeSelection = function (a) {
        this.allChecked = false;
        this.oneMonthChecked = false;
        this.threeMonthsChecked = false;
        this.sixMonthsChecked = false;
        this.yearToDateChecked = false;
        this.oneYearChecked = false;
        if (a == "1m") {
            this.oneMonthChecked = true;
        }
        else if (a == "3m") {
            this.threeMonthsChecked = true;
        }
        else if (a == "6m") {
            this.sixMonthsChecked = true;
        }
        else if (a == "YTD") {
            this.yearToDateChecked = true;
        }
        else if (a == "1y") {
            this.oneYearChecked = true;
        }
        else if (a == "all") {
            this.allChecked = true;
        }
        this.onRadioButtonChanged();
    };
    FinancialChartRangeSelectorViewModel.prototype.onRadioButtonChanged = function () {
        var a = dateFromTicks(this.selectionStart.getTime());
        var b = dateFromTicks(this.selectionEnd.getTime());
        this.selectionEnd = this.rangeEnd;
        if (this.oneMonthChecked) {
            this.selectionStart = this.oneMonthFromEnd;
        }
        if (this.threeMonthsChecked) {
            this.selectionStart = this.threeMonthsFromEnd;
        }
        if (this.sixMonthsChecked) {
            this.selectionStart = this.sixMonthsFromEnd;
        }
        if (this.yearToDateChecked) {
            this.selectionStart = this.firstDayOfEndYear;
        }
        if (this.oneYearChecked) {
            this.selectionStart = this.oneYearFromEnd;
        }
        if (this.allChecked) {
            this.selectionStart = this.rangeStart;
        }
        if (+(this.selectionStart) != +a || +(this.selectionEnd) != +b) {
            this.onRangeChanged();
            if (this.notifyChanged != null) {
                this.notifyChanged();
            }
        }
    };
    Object.defineProperty(FinancialChartRangeSelectorViewModel.prototype, "onRangeChanged", {
        get: function () {
            return this._onRangeChanged;
        },
        set: function (a) {
            this._onRangeChanged = a;
        },
        enumerable: false,
        configurable: true
    });
    FinancialChartRangeSelectorViewModel.$t = markType(FinancialChartRangeSelectorViewModel, 'FinancialChartRangeSelectorViewModel');
    return FinancialChartRangeSelectorViewModel;
}(Base));
export { FinancialChartRangeSelectorViewModel };
