import * as i1 from '@acorex/components/label';
import { AXLabelModule } from '@acorex/components/label';
import * as i2 from '@acorex/core/translation';
import { AXTranslationModule } from '@acorex/core/translation';
import * as i9 from '@angular/common';
import { DatePipe, AsyncPipe, CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Injectable, input, inject, signal, computed, effect, Component, model, output, untracked } from '@angular/core';
import * as i8 from '@acorex/components/button';
import { AXButtonModule } from '@acorex/components/button';
import * as i2$1 from '@acorex/components/datetime-box';
import { AXDateTimeBoxModule } from '@acorex/components/datetime-box';
import { AXFormModule } from '@acorex/components/form';
import * as i4 from '@acorex/components/number-box';
import { AXNumberBoxModule } from '@acorex/components/number-box';
import * as i7 from '@acorex/components/search-box';
import { AXSearchBoxModule } from '@acorex/components/search-box';
import * as i5 from '@acorex/components/select-box';
import { AXSelectBoxModule } from '@acorex/components/select-box';
import * as i3 from '@acorex/components/selection-list';
import { AXSelectionListModule } from '@acorex/components/selection-list';
import * as i1$1 from '@angular/forms';
import { FormsModule } from '@angular/forms';

/**
 * Service for working with RRule recurrence patterns.
 * Provides methods to create RRule instances from options or strings,
 * convert between formats, and query occurrences.
 */
class AXRruleService {
    /**
     * Creates an RRule instance from options object.
     * @param options Partial RRule options to create the rule from
     * @returns Promise resolving to the RRule instance
     */
    async rruleFromOptions(options) {
        // eslint-disable-next-line @nx/enforce-module-boundaries
        const { RRule } = await import('rrule');
        return new RRule(options);
    }
    /**
     * Creates an RRule instance from a RRULE string.
     * @param ruleString Valid RRULE string (e.g., "RRULE:FREQ=WEEKLY;COUNT=5")
     * @returns Promise resolving to the RRule instance
     */
    async rruleFromString(ruleString) {
        // eslint-disable-next-line @nx/enforce-module-boundaries
        const { RRule } = await import('rrule');
        return RRule.fromString(ruleString);
    }
    /**
     * Creates an RRule instance from human-readable text.
     * @param ruleText Human-readable text describing the recurrence (e.g., "every Monday for 5 weeks")
     * @returns Promise resolving to the RRule instance
     */
    async rruleFromText(ruleText) {
        // eslint-disable-next-line @nx/enforce-module-boundaries
        const { RRule } = await import('rrule');
        return RRule.fromText(ruleText);
    }
    /**
     * Extracts options from an RRule instance.
     * @param rule RRule instance to extract options from
     * @returns Parsed options with all required fields
     */
    rruleToOptions(rule) {
        return rule.options;
    }
    /**
     * Converts an RRule instance to RRULE string format.
     * @param rule RRule instance to convert
     * @returns RRULE string representation
     */
    rruleToString(rule) {
        return rule.toString();
    }
    /**
     * Converts an RRule instance to human-readable text.
     * @param rule RRule instance to convert
     * @returns Human-readable text description
     */
    rruleToText(rule) {
        return rule.toText();
    }
    /**
     * Gets all occurrences of the rule up to a limit.
     * @param rule RRule instance to query
     * @param limit Maximum number of occurrences to return (default: 500)
     * @returns Array of occurrence dates
     */
    rruleGetAll(rule, limit = 500) {
        return rule.all((d, l) => l < limit);
    }
    /**
     * Gets occurrences between two dates.
     * @param rule RRule instance to query
     * @param after Start date (exclusive by default)
     * @param before End date (exclusive by default)
     * @param inclusive Whether to include the boundary dates
     * @returns Array of occurrence dates between the specified dates
     */
    rruleGetBetween(rule, after, before, inclusive = false) {
        return rule.between(after, before, inclusive);
    }
    /**
     * Gets the last occurrence before the specified date.
     * @param rule RRule instance to query
     * @param date Date to search before
     * @param inclusive Whether to include the specified date
     * @returns Last occurrence before the date, or null if none found
     */
    rruleGetBefore(rule, date, inclusive = false) {
        return rule.before(date, inclusive);
    }
    /**
     * Gets the first occurrence after the specified date.
     * @param rule RRule instance to query
     * @param date Date to search after
     * @param inclusive Whether to include the specified date
     * @returns First occurrence after the date, or null if none found
     */
    rruleGetAfter(rule, date, inclusive = false) {
        return rule.after(date, inclusive);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRruleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRruleService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRruleService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

class AXRrulePreviewComponent {
    constructor() {
        this.value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : []));
        this.repeat = input(100, ...(ngDevMode ? [{ debugName: "repeat" }] : []));
        this.format = input('yyyy-MM-dd HH:mm:ss', ...(ngDevMode ? [{ debugName: "format" }] : []));
        this.rruleService = inject(AXRruleService);
        this.rrule = signal(null, ...(ngDevMode ? [{ debugName: "rrule" }] : []));
        this.timeZone = signal(null, ...(ngDevMode ? [{ debugName: "timeZone" }] : []));
        this.text = computed(() => (this.rrule() ? this.rruleService.rruleToText(this.rrule()) : ''), ...(ngDevMode ? [{ debugName: "text" }] : []));
        this.string = computed(() => (this.rrule() ? this.rruleService.rruleToString(this.rrule()) : ''), ...(ngDevMode ? [{ debugName: "string" }] : []));
        this.dates = computed(() => (this.rrule() ? this.rruleService.rruleGetAll(this.rrule(), this.repeat()) : []), ...(ngDevMode ? [{ debugName: "dates" }] : []));
        this.options = computed(() => (this.rrule() ? this.rruleService.rruleToOptions(this.rrule()) : {}), ...(ngDevMode ? [{ debugName: "options" }] : []));
        this.eff = effect(async () => {
            if (this.value()) {
                this.rrule.set(await this.rruleService.rruleFromString(this.value()));
            }
        }, ...(ngDevMode ? [{ debugName: "eff" }] : []));
    }
    ngOnInit() {
        this.timeZone.set(Intl.DateTimeFormat().resolvedOptions().timeZone);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRrulePreviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.3", type: AXRrulePreviewComponent, isStandalone: true, selector: "ax-rrule-preview", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, repeat: { classPropertyName: "repeat", publicName: "repeat", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
    <div class="ax-flex ax-flex-col ax-gap-4 ax-text-pretty ax-rounded-md ax-border ax-p-4">
      <div>
        <ax-label>{{ 'rrule.text' | translate: { scope: 'common' } | async }}</ax-label>
        <code class="ax-mt-2 ax-block ax-rounded ax-bg-surface ax-p-2">
          {{ text() }}
        </code>
      </div>
      <div>
        <ax-label>{{ 'rrule.string' | translate: { scope: 'common' } | async }}</ax-label>
        <code class="ax-mt-2 ax-block ax-text-pretty ax-break-all ax-rounded ax-bg-surface ax-p-2">
          {{ string() }}
        </code>
      </div>
      <div>
        <ax-label>{{
          'rrule.occurrences' | translate: { scope: 'common', params: { repeat: repeat() } } | async
        }}</ax-label>
        <div class="ax-mt-2 ax-max-h-64 ax-overflow-y-auto">
          @for (date of dates(); track $index) {
            <code class="ax-block ax-bg-surface ax-p-1 even:ax-bg-lighter">
              {{ date | date: format() : timeZone() }}
            </code>
          }
        </div>
      </div>
    </div>
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: AXLabelModule }, { kind: "component", type: i1.AXLabelComponent, selector: "ax-label", inputs: ["required", "for"], outputs: ["requiredChange"] }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "pipe", type: DatePipe, name: "date" }, { kind: "pipe", type: i2.AXTranslatorPipe, name: "translate" }, { kind: "pipe", type: AsyncPipe, name: "async" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRrulePreviewComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'ax-rrule-preview',
                    template: `
    <div class="ax-flex ax-flex-col ax-gap-4 ax-text-pretty ax-rounded-md ax-border ax-p-4">
      <div>
        <ax-label>{{ 'rrule.text' | translate: { scope: 'common' } | async }}</ax-label>
        <code class="ax-mt-2 ax-block ax-rounded ax-bg-surface ax-p-2">
          {{ text() }}
        </code>
      </div>
      <div>
        <ax-label>{{ 'rrule.string' | translate: { scope: 'common' } | async }}</ax-label>
        <code class="ax-mt-2 ax-block ax-text-pretty ax-break-all ax-rounded ax-bg-surface ax-p-2">
          {{ string() }}
        </code>
      </div>
      <div>
        <ax-label>{{
          'rrule.occurrences' | translate: { scope: 'common', params: { repeat: repeat() } } | async
        }}</ax-label>
        <div class="ax-mt-2 ax-max-h-64 ax-overflow-y-auto">
          @for (date of dates(); track $index) {
            <code class="ax-block ax-bg-surface ax-p-1 even:ax-bg-lighter">
              {{ date | date: format() : timeZone() }}
            </code>
          }
        </div>
      </div>
    </div>
  `,
                    imports: [AXLabelModule, DatePipe, AXTranslationModule, AsyncPipe],
                }]
        }] });

const freqs = [
    { text: 'Yearly', value: 0 },
    { text: 'Monthly', value: 1 },
    { text: 'Weekly', value: 2 },
    { text: 'Daily', value: 3 },
    { text: 'Hourly', value: 4 },
    { text: 'Minutely', value: 5 },
    { text: 'Secondly', value: 6 },
];
const weekdays = [
    { text: 'Sunday', value: 6 },
    { text: 'Monday', value: 0 },
    { text: 'Tuesday', value: 1 },
    { text: 'Wednesday', value: 2 },
    { text: 'Thursday', value: 3 },
    { text: 'Friday', value: 4 },
    { text: 'Saturday', value: 5 },
];
const months = [
    { text: 'January', value: 1 },
    { text: 'February', value: 2 },
    { text: 'March', value: 3 },
    { text: 'April', value: 4 },
    { text: 'May', value: 5 },
    { text: 'June', value: 6 },
    { text: 'July', value: 7 },
    { text: 'August', value: 8 },
    { text: 'September', value: 9 },
    { text: 'October', value: 10 },
    { text: 'November', value: 11 },
    { text: 'December', value: 12 },
];
const timezones = Intl.supportedValuesOf('timeZone');
const hours = Array.from({ length: 24 }, (_, i) => i);
const minutes = Array.from({ length: 60 }, (_, i) => i);
const seconds = Array.from({ length: 60 }, (_, i) => i);
const monthdays = Array.from({ length: 31 }, (_, i) => i + 1);
const nmonthdays = [
    ...Array.from({ length: 31 }, (_, i) => -1 * (i + 1)).reverse(),
    ...Array.from({ length: 31 }, (_, i) => i + 1),
];
const yeardays = Array.from({ length: 366 }, (_, i) => i + 1);
const weeknos = Array.from({ length: 53 }, (_, i) => i + 1);
const setpos = [
    ...Array.from({ length: 366 }, (_, i) => -1 * (i + 1)).reverse(),
    ...Array.from({ length: 366 }, (_, i) => i + 1),
];

const defaultOptions = {
    freq: 2,
    dtstart: null,
    interval: 1,
    wkst: null,
    count: 5,
    until: null,
    tzid: null,
    bysetpos: [],
    bymonth: [],
    bymonthday: [],
    byyearday: [],
    byweekno: [],
    byweekday: [],
    byhour: [],
    byminute: [],
    bysecond: [],
    byeaster: null,
    bynmonthday: [],
    bynweekday: [],
};
const defaultRrule = 'RRULE:FREQ=WEEKLY;INTERVAL=1;WKST=MO;COUNT=5';

/**
 * RRule component provides a user-friendly interface for creating and managing recurrence rules.
 * Supports various frequencies, intervals, and date constraints with real-time preview and validation.
 */
class AXRruleComponent {
    constructor() {
        /**
         * Current recurrence rule model value (options object or RRULE string).
         * @default null
         */
        this.value = model(null, ...(ngDevMode ? [{ debugName: "value" }] : []));
        /**
         * Emitted when the model value changes.
         */
        this.valueChange = output();
        /**
         * Emitted with the computed RRule instance when updated.
         */
        this.rruleChange = output();
        /**
         * Emitted with the normalized options whenever they change.
         */
        this.optionsChange = output();
        /**
         * Emitted with the RRULE string representation.
         */
        this.stringChange = output();
        /**
         * Emitted with the human-readable text of the rule.
         */
        this.textChange = output();
        this.freqs = freqs;
        this.weekdays = weekdays;
        this.months = months;
        this.timezones = timezones;
        this.hours = hours;
        this.minutes = minutes;
        this.seconds = seconds;
        this.monthdays = monthdays;
        this.nmonthdays = nmonthdays;
        this.yeardays = yeardays;
        this.weeknos = weeknos;
        this.setpos = setpos;
        this.options = signal({ ...defaultOptions }, ...(ngDevMode ? [{ debugName: "options" }] : []));
        this.rrule = signal(null, ...(ngDevMode ? [{ debugName: "rrule" }] : []));
        this.string = computed(() => this.rrule()?.toString() ?? null, ...(ngDevMode ? [{ debugName: "string" }] : []));
        this.text = computed(() => this.rrule()?.toText() ?? null, ...(ngDevMode ? [{ debugName: "text" }] : []));
        // public all = computed(() => this.rruleService.rruleGetAll(this.rrule()));
        this.rruleService = inject(AXRruleService);
        this._isUpdating = false;
        this._applyToken = 0;
        this.#valueEffect = effect(() => {
            const incoming = this.value();
            if (this._isUpdating) {
                this._isUpdating = false;
                return;
            }
            this._scheduleApplyIncoming(incoming);
        }, ...(ngDevMode ? [{ debugName: "#valueEffect" }] : []));
    }
    #valueEffect;
    _scheduleApplyIncoming(incoming) {
        const token = ++this._applyToken;
        // Defer to microtask to avoid doing async work directly inside effect
        Promise.resolve().then(() => this._applyIncomingAsync(incoming, token));
    }
    async _applyIncomingAsync(incoming, token) {
        try {
            let rrule;
            let newOptions;
            if (incoming) {
                if (typeof incoming === 'string') {
                    rrule = await this.rruleService.rruleFromString(incoming);
                    newOptions = this._clearOptions({ ...rrule.options }, incoming);
                }
                else {
                    rrule = await this.rruleService.rruleFromOptions(incoming);
                    newOptions = { ...rrule.options };
                }
            }
            else {
                rrule = await this.rruleService.rruleFromString(defaultRrule);
                newOptions = this._clearOptions({ ...rrule.options }, defaultRrule);
            }
            // Only apply the latest scheduled update
            if (token !== this._applyToken)
                return;
            untracked(() => {
                this.rrule.set(rrule);
                this.options.set(newOptions);
                this._emitAll();
            });
        }
        catch {
            // Swallow errors to avoid breaking the reactive graph; consider surfacing via output events if needed
        }
    }
    _emitAll() {
        this.rruleChange.emit(this.rrule());
        this.optionsChange.emit(this.options());
        this.stringChange.emit(this.string());
        this.textChange.emit(this.text());
    }
    _areOptionValuesEqual(a, b) {
        if (a === b)
            return true;
        if (a == null || b == null)
            return a === b;
        // Compare Date
        if (a instanceof Date && b instanceof Date)
            return a.getTime() === b.getTime();
        // Compare arrays of primitives
        if (Array.isArray(a) && Array.isArray(b)) {
            if (a.length !== b.length)
                return false;
            for (let i = 0; i < a.length; i++) {
                if (a[i] !== b[i])
                    return false;
            }
            return true;
        }
        return false;
    }
    _clearOptions(options, rule) {
        const upperCaseRule = rule.toUpperCase();
        if (!upperCaseRule.includes('DTSTART')) {
            options.dtstart = this.options().dtstart ?? new Date();
        }
        if (!upperCaseRule.includes('BYHOUR')) {
            options.byhour = [];
        }
        if (!upperCaseRule.includes('BYMINUTE')) {
            options.byminute = [];
        }
        if (!upperCaseRule.includes('BYSECOND')) {
            options.bysecond = [];
        }
        if (!upperCaseRule.includes('BYMONTH')) {
            options.bymonth = [];
        }
        if (!upperCaseRule.includes('BYMONTHDAY')) {
            options.bymonthday = [];
        }
        if (!upperCaseRule.includes('BYWEEKDAY')) {
            options.byweekday = [];
        }
        if (!upperCaseRule.includes('TZID')) {
            const currentTz = this.options().tzid;
            const userTimeZone = Intl?.DateTimeFormat?.().resolvedOptions?.().timeZone;
            options.tzid = currentTz ?? userTimeZone ?? null;
        }
        return options;
    }
    /**
     * Updates a single option and recomputes the rule.
     * @param key The option key to update
     * @param value The new value for the option
     */
    async updateOption(key, value) {
        const current = this.options()[key];
        if (this._areOptionValuesEqual(current, value))
            return;
        this.options.update((opts) => ({ ...opts, [key]: value }));
        const newRrule = await this.rruleService.rruleFromOptions(this.options());
        this.rrule.set(newRrule);
        this._isUpdating = true;
        if (typeof this.value() === 'string') {
            this.value.set(newRrule.toString());
        }
        else {
            this.value.set(this.options());
        }
        this._emitAll();
    }
    /**
     * Resets options to defaults and recomputes the rule.
     */
    async resetOptions() {
        this.options.set({ ...defaultOptions });
        const newRrule = await this.rruleService.rruleFromOptions(this.options());
        this.rrule.set(newRrule);
        this._isUpdating = true;
        if (typeof this.value() === 'string') {
            this.value.set(newRrule.toString());
        }
        else {
            this.value.set(this.options());
        }
        this._emitAll();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRruleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.3", type: AXRruleComponent, isStandalone: true, selector: "ax-rrule", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", valueChange: "valueChange", rruleChange: "rruleChange", optionsChange: "optionsChange", stringChange: "stringChange", textChange: "textChange" }, ngImport: i0, template: "<div class=\"ax-rrule-container ax-grid ax-grid-cols-1 ax-gap-4 md:ax-grid-cols-2 lg:ax-grid-cols-3\">\n  <!-- General -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.general' | translate: { scope: 'common' } | async }}</div>\n\n    <div>\n      <ax-label>{{ 'rrule.freq' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-selection-list\n        valueField=\"value\"\n        textField=\"text\"\n        name=\"freq\"\n        [items]=\"freqs\"\n        [ngModel]=\"options().freq\"\n        (ngModelChange)=\"updateOption('freq', $event)\"\n      ></ax-selection-list>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.dtstart' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-datetime-box\n        name=\"dtstart\"\n        [ngModel]=\"options().dtstart\"\n        (ngModelChange)=\"updateOption('dtstart', $event)\"\n      ></ax-datetime-box>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.until' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-datetime-box\n        name=\"until\"\n        [ngModel]=\"options().until\"\n        (ngModelChange)=\"updateOption('until', $event)\"\n      ></ax-datetime-box>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.count' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-number-box\n        name=\"count\"\n        [ngModel]=\"options().count\"\n        (ngModelChange)=\"updateOption('count', $event)\"\n        [minValue]=\"1\"\n      ></ax-number-box>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.interval' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-number-box\n        name=\"interval\"\n        [ngModel]=\"options().interval\"\n        (ngModelChange)=\"updateOption('interval', $event)\"\n        [minValue]=\"1\"\n      ></ax-number-box>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.tzid' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"tzid\"\n        [dataSource]=\"timezones\"\n        [ngModel]=\"options().tzid\"\n        (ngModelChange)=\"updateOption('tzid', $event)\"\n      >\n        <ax-search-box></ax-search-box>\n      </ax-select-box>\n    </div>\n  </div>\n\n  <!-- By Weekday -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.by-weekday' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.wkst' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-selection-list\n        valueField=\"value\"\n        textField=\"text\"\n        name=\"wkst\"\n        [items]=\"weekdays\"\n        [ngModel]=\"options().wkst\"\n        (ngModelChange)=\"updateOption('wkst', $event)\"\n      ></ax-selection-list>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-weekday-rule' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-selection-list\n        valueField=\"value\"\n        textField=\"text\"\n        name=\"byweekday\"\n        [items]=\"weekdays\"\n        multiple=\"true\"\n        [ngModel]=\"options().byweekday\"\n        (ngModelChange)=\"updateOption('byweekday', $event)\"\n      ></ax-selection-list>\n    </div>\n  </div>\n\n  <!-- By Month -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.by-month' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.by-month-rule' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-selection-list\n        valueField=\"value\"\n        textField=\"text\"\n        name=\"bymonth\"\n        [items]=\"months\"\n        multiple=\"true\"\n        [ngModel]=\"options().bymonth\"\n        (ngModelChange)=\"updateOption('bymonth', $event)\"\n      ></ax-selection-list>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-month-day' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"bymonthday\"\n        [dataSource]=\"monthdays\"\n        multiple=\"true\"\n        [ngModel]=\"options().bymonthday\"\n        (ngModelChange)=\"updateOption('bymonthday', $event)\"\n      >\n      </ax-select-box>\n    </div>\n    <!-- <div>\n      <ax-label>By Negative Month Day (BYNMONTHDAY)</ax-label>\n      <ax-select-box\n        name=\"bynmonthday\"\n        [dataSource]=\"nmonthdays\"\n        multiple=\"true\"\n        [ngModel]=\"options().bynmonthday\"\n        (ngModelChange)=\"updateOption('bynmonthday', $event)\"\n      >\n      </ax-select-box>\n    </div> -->\n  </div>\n\n  <!-- By Year -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.by-year' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.by-year-day' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"byyearday\"\n        [dataSource]=\"yeardays\"\n        multiple=\"true\"\n        [ngModel]=\"options().byyearday\"\n        (ngModelChange)=\"updateOption('byyearday', $event)\"\n      >\n      </ax-select-box>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-week-no' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"byweekno\"\n        [dataSource]=\"weeknos\"\n        multiple=\"true\"\n        [ngModel]=\"options().byweekno\"\n        (ngModelChange)=\"updateOption('byweekno', $event)\"\n      >\n      </ax-select-box>\n    </div>\n  </div>\n\n  <!-- By Time -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.by-time' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.by-hour' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"byhour\"\n        [dataSource]=\"hours\"\n        multiple=\"true\"\n        [ngModel]=\"options().byhour\"\n        (ngModelChange)=\"updateOption('byhour', $event)\"\n      >\n      </ax-select-box>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-minute' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"byminute\"\n        [dataSource]=\"minutes\"\n        multiple=\"true\"\n        [ngModel]=\"options().byminute\"\n        (ngModelChange)=\"updateOption('byminute', $event)\"\n      >\n      </ax-select-box>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-second' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"bysecond\"\n        [dataSource]=\"seconds\"\n        multiple=\"true\"\n        [ngModel]=\"options().bysecond\"\n        (ngModelChange)=\"updateOption('bysecond', $event)\"\n      >\n      </ax-select-box>\n    </div>\n  </div>\n\n  <!-- Advanced -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.advanced' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.by-set-pos' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"bysetpos\"\n        [dataSource]=\"setpos\"\n        multiple=\"true\"\n        [ngModel]=\"options().bysetpos\"\n        (ngModelChange)=\"updateOption('bysetpos', $event)\"\n      >\n      </ax-select-box>\n    </div>\n  </div>\n</div>\n\n<div class=\"ax-flex ax-justify-end ax-py-4\">\n  <ax-button [text]=\"'rrule.reset' | translate: { scope: 'common' } | async\" (click)=\"resetOptions()\"></ax-button>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: AXDateTimeBoxModule }, { kind: "component", type: i2$1.AXDateTimeBoxComponent, selector: "ax-datetime-box", inputs: ["disabled", "readonly", "tabIndex", "placeholder", "minValue", "maxValue", "value", "state", "name", "depth", "id", "type", "look", "holidayDates", "allowTyping", "picker", "calendar", "weekend", "weekdays", "format"], outputs: ["valueChange", "stateChange", "onValueChanged", "onBlur", "onFocus", "onOpened", "onClosed", "readonlyChange", "disabledChange", "formatChange"] }, { kind: "ngmodule", type: AXSelectionListModule }, { kind: "component", type: i3.AXSelectionListComponent, selector: "ax-selection-list", inputs: ["id", "name", "disabled", "readonly", "tabIndex", "size", "value", "valueField", "textField", "disabledField", "readonlyField", "multiple", "direction", "customTemplate", "showControl", "items", "look"], outputs: ["onValueChanged", "onBlur", "onFocus"] }, { kind: "ngmodule", type: AXNumberBoxModule }, { kind: "component", type: i4.AXNumberBoxComponent, selector: "ax-number-box", inputs: ["disabled", "readonly", "tabIndex", "placeholder", "value", "state", "name", "id", "look", "minValue", "maxValue", "showSpinButtons", "thousandsSeparator", "decimals", "changeOnScroll", "step"], outputs: ["valueChange", "stateChange", "onValueChanged", "onBlur", "onFocus", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress", "thousandsSeparatorChange"] }, { kind: "ngmodule", type: AXFormModule }, { kind: "ngmodule", type: AXSelectBoxModule }, { kind: "component", type: i5.AXSelectBoxComponent, selector: "ax-select-box", inputs: ["disabled", "readonly", "tabIndex", "placeholder", "minValue", "maxValue", "value", "state", "name", "id", "type", "look", "multiple", "valueField", "textField", "disabledField", "textTemplate", "selectedItems", "isItemTruncated", "showItemTooltip", "itemHeight", "maxVisibleItems", "dataSource", "minRecordsForSearch", "caption", "itemTemplate", "selectedTemplate", "emptyTemplate", "loadingTemplate", "dropdownWidth", "searchBoxAutoFocus"], outputs: ["valueChange", "stateChange", "onValueChanged", "onBlur", "onFocus", "readonlyChange", "disabledChange", "onOpened", "onClosed", "onItemSelected", "onItemClick"] }, { kind: "ngmodule", type: AXLabelModule }, { kind: "component", type: i1.AXLabelComponent, selector: "ax-label", inputs: ["required", "for"], outputs: ["requiredChange"] }, { kind: "ngmodule", type: AXSearchBoxModule }, { kind: "component", type: i7.AXSearchBoxComponent, selector: "ax-search-box", inputs: ["disabled", "readonly", "tabIndex", "placeholder", "value", "state", "name", "id", "look", "class", "delayTime", "type", "autoSearch"], outputs: ["valueChange", "stateChange", "onValueChanged", "onBlur", "onFocus", "readonlyChange", "disabledChange", "onKeyDown", "onKeyUp", "onKeyPress"] }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i8.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "pipe", type: i9.AsyncPipe, name: "async" }, { kind: "pipe", type: i2.AXTranslatorPipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: AXRruleComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, selector: 'ax-rrule', imports: [
                        CommonModule,
                        FormsModule,
                        AXDateTimeBoxModule,
                        AXSelectionListModule,
                        AXNumberBoxModule,
                        AXFormModule,
                        AXSelectBoxModule,
                        AXLabelModule,
                        AXSearchBoxModule,
                        AXButtonModule,
                        AXTranslationModule,
                    ], template: "<div class=\"ax-rrule-container ax-grid ax-grid-cols-1 ax-gap-4 md:ax-grid-cols-2 lg:ax-grid-cols-3\">\n  <!-- General -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.general' | translate: { scope: 'common' } | async }}</div>\n\n    <div>\n      <ax-label>{{ 'rrule.freq' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-selection-list\n        valueField=\"value\"\n        textField=\"text\"\n        name=\"freq\"\n        [items]=\"freqs\"\n        [ngModel]=\"options().freq\"\n        (ngModelChange)=\"updateOption('freq', $event)\"\n      ></ax-selection-list>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.dtstart' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-datetime-box\n        name=\"dtstart\"\n        [ngModel]=\"options().dtstart\"\n        (ngModelChange)=\"updateOption('dtstart', $event)\"\n      ></ax-datetime-box>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.until' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-datetime-box\n        name=\"until\"\n        [ngModel]=\"options().until\"\n        (ngModelChange)=\"updateOption('until', $event)\"\n      ></ax-datetime-box>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.count' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-number-box\n        name=\"count\"\n        [ngModel]=\"options().count\"\n        (ngModelChange)=\"updateOption('count', $event)\"\n        [minValue]=\"1\"\n      ></ax-number-box>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.interval' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-number-box\n        name=\"interval\"\n        [ngModel]=\"options().interval\"\n        (ngModelChange)=\"updateOption('interval', $event)\"\n        [minValue]=\"1\"\n      ></ax-number-box>\n    </div>\n\n    <div>\n      <ax-label>{{ 'rrule.tzid' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"tzid\"\n        [dataSource]=\"timezones\"\n        [ngModel]=\"options().tzid\"\n        (ngModelChange)=\"updateOption('tzid', $event)\"\n      >\n        <ax-search-box></ax-search-box>\n      </ax-select-box>\n    </div>\n  </div>\n\n  <!-- By Weekday -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.by-weekday' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.wkst' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-selection-list\n        valueField=\"value\"\n        textField=\"text\"\n        name=\"wkst\"\n        [items]=\"weekdays\"\n        [ngModel]=\"options().wkst\"\n        (ngModelChange)=\"updateOption('wkst', $event)\"\n      ></ax-selection-list>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-weekday-rule' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-selection-list\n        valueField=\"value\"\n        textField=\"text\"\n        name=\"byweekday\"\n        [items]=\"weekdays\"\n        multiple=\"true\"\n        [ngModel]=\"options().byweekday\"\n        (ngModelChange)=\"updateOption('byweekday', $event)\"\n      ></ax-selection-list>\n    </div>\n  </div>\n\n  <!-- By Month -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.by-month' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.by-month-rule' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-selection-list\n        valueField=\"value\"\n        textField=\"text\"\n        name=\"bymonth\"\n        [items]=\"months\"\n        multiple=\"true\"\n        [ngModel]=\"options().bymonth\"\n        (ngModelChange)=\"updateOption('bymonth', $event)\"\n      ></ax-selection-list>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-month-day' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"bymonthday\"\n        [dataSource]=\"monthdays\"\n        multiple=\"true\"\n        [ngModel]=\"options().bymonthday\"\n        (ngModelChange)=\"updateOption('bymonthday', $event)\"\n      >\n      </ax-select-box>\n    </div>\n    <!-- <div>\n      <ax-label>By Negative Month Day (BYNMONTHDAY)</ax-label>\n      <ax-select-box\n        name=\"bynmonthday\"\n        [dataSource]=\"nmonthdays\"\n        multiple=\"true\"\n        [ngModel]=\"options().bynmonthday\"\n        (ngModelChange)=\"updateOption('bynmonthday', $event)\"\n      >\n      </ax-select-box>\n    </div> -->\n  </div>\n\n  <!-- By Year -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.by-year' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.by-year-day' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"byyearday\"\n        [dataSource]=\"yeardays\"\n        multiple=\"true\"\n        [ngModel]=\"options().byyearday\"\n        (ngModelChange)=\"updateOption('byyearday', $event)\"\n      >\n      </ax-select-box>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-week-no' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"byweekno\"\n        [dataSource]=\"weeknos\"\n        multiple=\"true\"\n        [ngModel]=\"options().byweekno\"\n        (ngModelChange)=\"updateOption('byweekno', $event)\"\n      >\n      </ax-select-box>\n    </div>\n  </div>\n\n  <!-- By Time -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.by-time' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.by-hour' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"byhour\"\n        [dataSource]=\"hours\"\n        multiple=\"true\"\n        [ngModel]=\"options().byhour\"\n        (ngModelChange)=\"updateOption('byhour', $event)\"\n      >\n      </ax-select-box>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-minute' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"byminute\"\n        [dataSource]=\"minutes\"\n        multiple=\"true\"\n        [ngModel]=\"options().byminute\"\n        (ngModelChange)=\"updateOption('byminute', $event)\"\n      >\n      </ax-select-box>\n    </div>\n    <div>\n      <ax-label>{{ 'rrule.by-second' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"bysecond\"\n        [dataSource]=\"seconds\"\n        multiple=\"true\"\n        [ngModel]=\"options().bysecond\"\n        (ngModelChange)=\"updateOption('bysecond', $event)\"\n      >\n      </ax-select-box>\n    </div>\n  </div>\n\n  <!-- Advanced -->\n  <div class=\"ax-flex ax-flex-col ax-gap-4 ax-rounded-md ax-border ax-p-4\">\n    <div class=\"ax-text-lg ax-font-semibold\">{{ 'rrule.advanced' | translate: { scope: 'common' } | async }}</div>\n    <div>\n      <ax-label>{{ 'rrule.by-set-pos' | translate: { scope: 'common' } | async }}</ax-label>\n      <ax-select-box\n        name=\"bysetpos\"\n        [dataSource]=\"setpos\"\n        multiple=\"true\"\n        [ngModel]=\"options().bysetpos\"\n        (ngModelChange)=\"updateOption('bysetpos', $event)\"\n      >\n      </ax-select-box>\n    </div>\n  </div>\n</div>\n\n<div class=\"ax-flex ax-justify-end ax-py-4\">\n  <ax-button [text]=\"'rrule.reset' | translate: { scope: 'common' } | async\" (click)=\"resetOptions()\"></ax-button>\n</div>\n" }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { AXRruleComponent, AXRrulePreviewComponent, AXRruleService, defaultOptions, defaultRrule };
//# sourceMappingURL=acorex-components-rrule.mjs.map
