/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-shadow */
// #region Imports
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { isDateEqual, isDateInDates } from '../../../../../Extensions/DateExtensions';
import { Appearanceable } from '../../../../Behaviors/Appearanceable';
import { Themeable } from '../../../../Behaviors/Themeable';
import { Variantable } from '../../../../Behaviors/Variantable';
import { Attribute } from '../../../../Decorators/AttributeDecorator';
import { Component } from '../../../../Decorators/ComponentDecorator';
import { CalendarView } from '../../../../Types/CalendarView';
import { ButtonElement } from '../../../Buttons/Button/ButtonElement';
import { TextElement } from '../../../Primitives/Text/TextElement';
import { CalendarItemElement } from '../CalendarItemElement';
import { CalendarViewBaseElement } from './Abstracts/CalendarViewBase';
import { calendarMonthsViewElementTemplate } from './CalendarMonthsViewElementTemplate';
import { calendarMonthsViewElementCosmopolitanStyle } from './Themes/CalendarMonthsViewElement.Cosmopolitan';
import { calendarMonthsViewElementJoyStyle } from './Themes/CalendarMonthsViewElement.Joy';
import { calendarMonthsViewElementMemphisStyle } from './Themes/CalendarMonthsViewElement.Memphis';
// #endregion
/**
 * Calendar Months View - A component that displays a view of months in a calendar, allowing users to select a month.
 *
 * @description
 * The Calendar Months View component presents a grid of months within a calendar format. Users can navigate through and
 * select a specific month from the displayed options. This view is typically used within a date picker or calendar
 * component to help users choose a month for date selection or scheduling purposes.
 *
 * @name CalendarMonthsView
 * @element mosaik-calendar-months-view
 * @category Calendar
 *
 * @slot header - The header slot.
 *
 * @csspart heading - The heading part.
 * @csspart item - The item part.
 * @csspart month - The month part.
 * @csspart monthView - The month view part.
 * @csspart navigation - The navigation part.
 *
 * @cssprop {String} --calendar-months-view-font-family - The months view font family CSS custom property.
 * @cssprop {String} --calendar-months-view-font-letter-spacing - The months view font letter spacing CSS custom property.
 * @cssprop {String} --calendar-months-view-font-line-height - The months view font line height CSS custom property.
 * @cssprop {String} --calendar-months-view-font-size - The months view font size CSS custom property.
 * @cssprop {String} --calendar-months-view-font-text-decoration - The months view font text decoration CSS custom property.
 * @cssprop {String} --calendar-months-view-font-text-transform - The months view font text transform CSS custom property.
 * @cssprop {String} --calendar-months-view-font-weight - The months view font weight CSS custom property.
 * @cssprop {String} --calendar-months-view-gap
 * @cssprop {String} --calendar-months-view-padding-bottom
 * @cssprop {String} --calendar-months-view-padding-left
 * @cssprop {String} --calendar-months-view-padding-right
 * @cssprop {String} --calendar-months-view-padding-top
 * @cssprop {String} --calendar-months-view-shadow - The months view shadow CSS custom property.
 * @cssprop {String} --calendar-months-view-shadow-blur - The months view shadow blur CSS custom property.
 * @cssprop {String} --calendar-months-view-shadow-color - The months view shadow color CSS custom property.
 * @cssprop {String} --calendar-months-view-shadow-offset-x - The months view shadow offset x CSS custom property.
 * @cssprop {String} --calendar-months-view-shadow-offset-y - The months view shadow offset y CSS custom property.
 * @cssprop {String} --calendar-months-view-shadow-spread - The months view shadow spread CSS custom property.
 * @cssprop {String} --calendar-months-view-transition-duration - The months view transition duration CSS custom property.
 * @cssprop {String} --calendar-months-view-transition-mode - The months view transition mode CSS custom property.
 * @cssprop {String} --calendar-months-view-transition-property - The months view transition property CSS custom property.
 * @cssprop {String} --calendar-months-view-translate - The months view translate CSS custom property.
 *
 * @dependency mosaik-button - The Button element.
 * @dependency mosaik-button-group - The Button Group element.
 * @dependency mosaik-calendar-item - The Calendar Item element.
 *
 * @example
 * Basic calendar months view:
 * ```html
 * <mosaik-calendar-months-view></mosaik-calendar-months-view>
 * ```
 *
 * @example
 * Calendar months view with short format:
 * ```html
 * <mosaik-calendar-months-view format="short"></mosaik-calendar-months-view>
 * ```
 *
 * @public
 */
let CalendarMonthsViewElement = class CalendarMonthsViewElement extends Themeable(Appearanceable(Variantable(CalendarViewBaseElement))) {
    // #region Fields
    _format;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._format = 'short';
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-calendar-months-view';
    }
    /**
     * Gets or sets the `format` property.
     *
     * @public
     * @attr
     */
    get format() {
        return this._format;
    }
    set format(value) {
        if (this._format !== value) {
            this._format = value;
            this.requestUpdate('format');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     * @template
     */
    selectMonth(month) {
        this.displayDate?.setMonth(month);
        this.value?.setMonth(month);
        if (this.value === undefined) {
            console.error('[CalendarMonthsViewElement] Value is not set.');
        }
        const date = this.value;
        this.onValueChanged({
            value: {
                date: date,
                isAdjacent: false, // TODO: Implement
                isBlackout: isDateInDates(date, this.blackoutDates),
                isSpecial: isDateInDates(date, this.specialDates),
                isToday: isDateEqual(date, new Date()),
                isWeekend: date.getDay() === 0 || date.getDay() === 6
            },
            values: this.values?.map((date) => ({
                date: date,
                isAdjacent: false, // TODO: Implement
                isBlackout: isDateInDates(date, this.blackoutDates),
                isSpecial: isDateInDates(date, this.specialDates),
                isToday: isDateEqual(date, new Date()),
                isWeekend: date.getDay() === 0 || date.getDay() === 6
            }))
        });
        if (this.allowedViews.includes(CalendarView.Day)) {
            this.setView(CalendarView.Day);
        }
    }
    /**
     * @protected
     * @template
     */
    setView(view) {
        this.onViewChanged({ view: view });
    }
};
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], CalendarMonthsViewElement.prototype, "format", null);
CalendarMonthsViewElement = __decorate([
    Component({
        selector: 'mosaik-calendar-months-view',
        template: calendarMonthsViewElementTemplate,
        themes: {
            joy: calendarMonthsViewElementJoyStyle,
            memphis: calendarMonthsViewElementMemphisStyle,
            cosmopolitan: calendarMonthsViewElementCosmopolitanStyle
        },
        imports: [
            TextElement,
            ButtonElement,
            CalendarItemElement
        ]
    }),
    __metadata("design:paramtypes", [])
], CalendarMonthsViewElement);
export { CalendarMonthsViewElement };
//# sourceMappingURL=CalendarMonthsViewElement.js.map