// 节日福利表单 Alpine 工厂，提供周期、分配和目标范围的联动状态。

/**
 * 创建节日福利表单状态对象。
 *
 * @param {object} config
 * @returns {object}
 */
function createHolidayEventForm(config = {}) {
    return {
        repeatType: config.repeatType ?? "once",
        distributeType: config.distributeType ?? "random",
        targetType: config.targetType ?? "all",
        scheduleMonth: config.scheduleMonth ?? "1",
        scheduleDay: config.scheduleDay ?? "1",
        scheduleTime: config.scheduleTime ?? "20:00",
        durationDays: config.durationDays ?? "1",
        dailyOccurrences: config.dailyOccurrences ?? "1",
        occurrenceIntervalMinutes: config.occurrenceIntervalMinutes ?? "60",

        /**
         * 生成年节日循环计划摘要，供表单实时预览。
         *
         * @returns {string}
         */
        yearlySummary() {
            return `每年 ${this.scheduleMonth} 月 ${this.scheduleDay} 日 ${this.scheduleTime}，连续 ${this.durationDays} 天，每天 ${this.dailyOccurrences} 次 / ${this.occurrenceIntervalMinutes} 分钟`;
        },
    };
}

window.holidayEventForm = createHolidayEventForm;
