/**
 * DevExtreme (cjs/__internal/ui/calendar/m_calendar.multiple.selection.strategy.js)
 * Version: 23.2.9 (build 24294-0112)
 * Build date: Sun Oct 20 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.default = void 0;
var _m_calendarSelection = _interopRequireDefault(require("./m_calendar.selection.strategy"));

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}

function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    _setPrototypeOf(subClass, superClass)
}

function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
        o.__proto__ = p;
        return o
    };
    return _setPrototypeOf(o, p)
}
let CalendarMultiSelectionStrategy = function(_CalendarSelectionStr) {
    _inheritsLoose(CalendarMultiSelectionStrategy, _CalendarSelectionStr);

    function CalendarMultiSelectionStrategy(component) {
        var _this;
        _this = _CalendarSelectionStr.call(this, component) || this;
        _this.NAME = "MultiSelection";
        return _this
    }
    var _proto = CalendarMultiSelectionStrategy.prototype;
    _proto.getViewOptions = function() {
        return {
            value: this.dateOption("value"),
            range: [],
            selectionMode: "multiple",
            onWeekNumberClick: this._shouldHandleWeekNumberClick() ? this._weekNumberClickHandler.bind(this) : null
        }
    };
    _proto.selectValue = function(selectedValue, e) {
        const value = [...this.dateOption("value")];
        const alreadySelectedIndex = value.findIndex(date => (null === date || void 0 === date ? void 0 : date.toDateString()) === selectedValue.toDateString());
        if (alreadySelectedIndex > -1) {
            value.splice(alreadySelectedIndex, 1)
        } else {
            value.push(selectedValue)
        }
        this.skipNavigate();
        this._updateCurrentDate(selectedValue);
        this._currentDateChanged = true;
        this.dateValue(value, e)
    };
    _proto.updateAriaSelected = function(value, previousValue) {
        null !== value && void 0 !== value ? value : value = this.dateOption("value");
        null !== previousValue && void 0 !== previousValue ? previousValue : previousValue = [];
        _CalendarSelectionStr.prototype.updateAriaSelected.call(this, value, previousValue)
    };
    _proto.getDefaultCurrentDate = function() {
        const dates = this.dateOption("value").filter(value => value);
        return this._getLowestDateInArray(dates)
    };
    _proto.restoreValue = function() {
        this.calendar.option("value", [])
    };
    _proto._weekNumberClickHandler = function(_ref) {
        let {
            rowDates: rowDates,
            event: event
        } = _ref;
        const selectedDates = rowDates.filter(date => !this._isDateDisabled(date));
        this.dateValue(selectedDates, event)
    };
    return CalendarMultiSelectionStrategy
}(_m_calendarSelection.default);
var _default = CalendarMultiSelectionStrategy;
exports.default = _default;
