import { AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex/platform/auth';
import { AXPSearchCommandProvider, AXP_MENU_PROVIDER, AXP_SEARCH_PROVIDER, createAllQueryView, AXPEntityQueryType, AXPEntityCommandScope } from '@acorex/platform/common';
import { AXMEntityCrudServiceImpl, AXPEntityService, AXP_ENTITY_DEFINITION_LOADER, entityMasterCrudActions, entityMasterRecordActions, entityDetailsCrudActions, entityMasterDeleteAction, entityDetailsSimpleCondition } from '@acorex/platform/layout/entity';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Injectable, NgModule, inject, Injector } from '@angular/core';
import { AXTranslationService } from '@acorex/core/translation';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';

const config = {
    i18n: 'calendar-management',
    module: 'CalendarManagement'
};
const RootConfig = {
    config,
    module: {
        name: config.module,
        title: `@${config.i18n}:module-name`,
        icon: 'fa-light fa-calendar',
    },
    entities: {
        calendar: {
            name: 'Calendar',
            title: `@${config.i18n}:calendar.individual-title`,
            titlePlural: `@${config.i18n}:calendar.plural-title`,
            icon: 'fa-light fa-calendar',
        },
        calendarEvent: {
            name: 'CalendarEvent',
            title: `@${config.i18n}:calendar-event.individual-title`,
            titlePlural: `@${config.i18n}:calendar-event.plural-title`,
            icon: 'fa-light fa-calendar-day',
        },
        calendarEventType: {
            name: 'CalendarEventType',
            title: `@${config.i18n}:calendar-event-type.individual-title`,
            titlePlural: `@${config.i18n}:calendar-event-type.plural-title`,
            icon: 'fa-light fa-tag',
        },
    },
};

class AXMCalendarService extends AXMEntityCrudServiceImpl {
}
class AXMCalendarServiceImpl extends AXMCalendarService {
    constructor() {
        super(`${RootConfig.module.name}.${RootConfig.entities.calendar.name}`);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarServiceImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarServiceImpl }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarServiceImpl, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });

class AXMCalendarEntityModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEntityModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEntityModule }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEntityModule, providers: [
            {
                provide: AXMCalendarService,
                useClass: AXMCalendarServiceImpl,
            },
        ] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEntityModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [],
                    exports: [],
                    declarations: [],
                    providers: [
                        {
                            provide: AXMCalendarService,
                            useClass: AXMCalendarServiceImpl,
                        },
                    ],
                }]
        }] });

//#region ----   Abstract Service   ----
class AXMCalendarEventService extends AXMEntityCrudServiceImpl {
}
//#endregion
//#region ----   Concrete Implementation   ----
class AXMCalendarEventServiceImpl extends AXMCalendarEventService {
    constructor() {
        super(`${RootConfig.module.name}.${RootConfig.entities.calendarEvent.name}`);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventServiceImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventServiceImpl }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventServiceImpl, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });

class AXMCalendarEventEntityModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventEntityModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventEntityModule }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventEntityModule, providers: [
            {
                provide: AXMCalendarEventService,
                useClass: AXMCalendarEventServiceImpl,
            },
        ] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventEntityModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [],
                    exports: [],
                    declarations: [],
                    providers: [
                        {
                            provide: AXMCalendarEventService,
                            useClass: AXMCalendarEventServiceImpl,
                        },
                    ],
                }]
        }] });

//#region ----   Abstract Service   ----
class AXMCalendarEventTypeService extends AXMEntityCrudServiceImpl {
}
//#endregion
//#region ----   Concrete Implementation   ----
class AXMCalendarEventTypeServiceImpl extends AXMCalendarEventTypeService {
    constructor() {
        super(`${RootConfig.module.name}.${RootConfig.entities.calendarEventType.name}`);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventTypeServiceImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventTypeServiceImpl }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventTypeServiceImpl, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });

class AXMCalendarEventTypeEntityModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventTypeEntityModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventTypeEntityModule }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventTypeEntityModule, providers: [
            {
                provide: AXMCalendarEventTypeService,
                useClass: AXMCalendarEventTypeServiceImpl,
            },
        ] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarEventTypeEntityModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [],
                    exports: [],
                    declarations: [],
                    providers: [
                        {
                            provide: AXMCalendarEventTypeService,
                            useClass: AXMCalendarEventTypeServiceImpl,
                        },
                    ],
                }]
        }] });

// Entity Modules

class AXMCalendarManagementEntityProvider {
    constructor() {
        this.injector = inject(Injector);
    }
    preload() {
        const module = RootConfig.module.name;
        return Array.from(Object.values(RootConfig.entities)).map((entity) => ({
            module: module,
            entity: entity.name,
        }));
    }
    async get(moduleName, entityName) {
        if (moduleName == RootConfig.module.name) {
            switch (entityName) {
                case RootConfig.entities.calendar.name:
                    return (await Promise.resolve().then(function () { return calendar_entity; })).calendarFactory(this.injector);
                case RootConfig.entities.calendarEvent.name:
                    return (await Promise.resolve().then(function () { return calendarEvent_entity; })).calendarEventFactory(this.injector);
                case RootConfig.entities.calendarEventType.name:
                    return (await Promise.resolve().then(function () { return calendarEventType_entity; })).calendarEventTypeFactory(this.injector);
            }
        }
        return null;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementEntityProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementEntityProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementEntityProvider, decorators: [{
            type: Injectable
        }] });

const AXPCalendarManagementMenuKeys = {
    Root: 'calendar-management:menu',
    Calendars: 'calendar-management:menu:calendars',
    CalendarEventTypes: 'calendar-management:menu:calendar-event-types',
};

class AXMCalendarManagementMenuProvider {
    constructor() {
        this.entityService = inject(AXPEntityService);
    }
    async provide(context) {
        const module = RootConfig.module;
        context.addItems([
            {
                name: AXPCalendarManagementMenuKeys.Root,
                priority: 9003,
                text: '@calendar-management:root-menu',
                icon: module.icon,
                data: {
                //requiredPermission: ['calendar.management']
                },
                children: [
                    {
                        name: AXPCalendarManagementMenuKeys.Calendars,
                        text: '@calendar-management:calendar.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.calendar.name),
                        icon: RootConfig.entities.calendar.icon,
                        priority: 1,
                    },
                    {
                        name: AXPCalendarManagementMenuKeys.CalendarEventTypes,
                        text: '@calendar-management:calendar-event-type.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.calendarEventType.name),
                        icon: RootConfig.entities.calendarEventType.icon,
                        priority: 3,
                    },
                ],
            },
        ]);
    }
}

class AXMCalendarManagementPermissionDefinitionProvider {
    constructor(injector) {
        this.injector = injector;
        this.translateService = this.injector.get(AXTranslationService);
    }
    async define(context) {
        const trans = async (key) => await this.translateService.translateAsync(`permissions.calendar-management.${key}`, {
            scope: 'calendar-management'
        });
        context.addGroup('calendar-management', await trans('manage.title'))
            // Calendar Management
            .addPermission('calendar.management', await trans('calendar.manage.title'))
            .addChild('calendar.view', await trans('calendar.view.title'))
            .addChild('calendar.create', await trans('calendar.create.title'))
            .addChild('calendar.update', await trans('calendar.update.title'))
            .addChild('calendar.delete', await trans('calendar.delete.title'))
            .endPermission()
            // Calendar Event Type Management
            .addPermission('calendar-event-type.management', await trans('calendar-event-type.manage.title'))
            .addChild('calendar-event-type.view', await trans('calendar-event-type.view.title'))
            .addChild('calendar-event-type.create', await trans('calendar-event-type.create.title'))
            .addChild('calendar-event-type.update', await trans('calendar-event-type.update.title'))
            .addChild('calendar-event-type.delete', await trans('calendar-event-type.delete.title'))
            .endPermission()
            // Administrative Permissions
            .addPermission('calendar.admin', await trans('calendar.admin.title'))
            .endPermission()
            .endGroup();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementPermissionDefinitionProvider, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementPermissionDefinitionProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementPermissionDefinitionProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

class AXMCalendarManagementSearchCommandProvider extends AXPSearchCommandProvider {
    constructor() {
        super(...arguments);
        this.commands = [];
    }
}

class AXMCalendarManagementModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementModule, imports: [CommonModule,
            // Entity Modules
            AXMCalendarEntityModule,
            AXMCalendarEventEntityModule,
            AXMCalendarEventTypeEntityModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementModule, providers: [
            // Module Providers
            {
                provide: AXP_ENTITY_DEFINITION_LOADER,
                useClass: AXMCalendarManagementEntityProvider,
                multi: true,
            },
            {
                provide: AXP_MENU_PROVIDER,
                useClass: AXMCalendarManagementMenuProvider,
                multi: true,
            },
            {
                provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                useClass: AXMCalendarManagementPermissionDefinitionProvider,
                multi: true,
            },
            {
                provide: AXP_SEARCH_PROVIDER,
                useClass: AXMCalendarManagementSearchCommandProvider,
                multi: true,
            },
        ], imports: [CommonModule,
            // Entity Modules
            AXMCalendarEntityModule,
            AXMCalendarEventEntityModule,
            AXMCalendarEventTypeEntityModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        CommonModule,
                        // Entity Modules
                        AXMCalendarEntityModule,
                        AXMCalendarEventEntityModule,
                        AXMCalendarEventTypeEntityModule,
                    ],
                    providers: [
                        // Module Providers
                        {
                            provide: AXP_ENTITY_DEFINITION_LOADER,
                            useClass: AXMCalendarManagementEntityProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_MENU_PROVIDER,
                            useClass: AXMCalendarManagementMenuProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                            useClass: AXMCalendarManagementPermissionDefinitionProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SEARCH_PROVIDER,
                            useClass: AXMCalendarManagementSearchCommandProvider,
                            multi: true,
                        },
                    ],
                }]
        }] });

async function calendarEventTypeFactory(injector) {
    const dataService = injector.get(AXMCalendarEventTypeService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.calendarEventType.name,
        title: RootConfig.entities.calendarEventType.title,
        icon: RootConfig.entities.calendarEventType.icon,
        formats: {
            individual: RootConfig.entities.calendarEventType.title,
            plural: RootConfig.entities.calendarEventType.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ description }}',
            },
        },
        plugins: [
            { name: 'history' },
            { name: 'lock' },
            { name: 'compare' },
        ],
        //#region ----   Property Groups   ----
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
            {
                id: 'appearance',
                title: '@general:terms.interface.appearance',
            },
            {
                id: 'settings',
                title: '@general:terms.interface.settings',
            },
        ],
        //#endregion
        //#region ----   Properties   ----
        properties: [
            // Basic Information
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'Enter event type title',
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.largeText,
                        options: {
                            rows: 3,
                            placeholder: 'Enter event type description',
                        },
                    },
                },
            },
            // Appearance
            {
                name: 'color',
                title: '@general:terms.common.color',
                groupId: 'appearance',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.color,
                        options: {
                            format: 'hex',
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            {
                name: 'icon',
                title: '@general:terms.common.icon',
                groupId: 'appearance',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'fa-light fa-icon-name',
                        },
                    },
                },
            },
            // Settings
            {
                name: 'isActive',
                title: '@general:terms.status.states.is-active',
                groupId: 'settings',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
            {
                name: 'isDefault',
                title: '@calendar-management:calendar-event-type.is-default',
                groupId: 'settings',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
            {
                name: 'order',
                title: '@general:terms.classification.order',
                groupId: 'settings',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsCatalog.number,
                        options: {
                            minValue: 0,
                            maxValue: 9999,
                        },
                    },
                },
            },
        ],
        //#endregion
        //#region ----   Table Columns   ----
        columns: [
            { name: 'title' },
            { name: 'color' },
            { name: 'icon' },
            { name: 'isDefault' },
            { name: 'isActive' },
        ],
        //#endregion
        //#region ----   Commands   ----
        commands: {
            create: {
                execute: async (data) => {
                    const res = await dataService.insertOne(data);
                    return { id: res };
                },
            },
            delete: {
                execute: async (id) => {
                    return await dataService.deleteOne(id);
                },
            },
            update: {
                execute: async (data) => {
                    return await dataService.updateOne(data.id, data);
                },
            },
        },
        //#endregion
        //#region ----   Queries   ----
        queries: {
            byKey: {
                execute: async (id) => {
                    return await dataService.getOne(id);
                },
                type: AXPEntityQueryType.Single,
            },
            list: {
                execute: async (e) => {
                    return await dataService.query({ skip: e.skip, take: e.take, filter: e.filter });
                },
                type: AXPEntityQueryType.List,
            },
        },
        //#endregion
        //#region ----   Interface Layouts   ----
        interfaces: {
            master: {
                create: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'appearance' },
                        { id: 'settings' },
                    ],
                    properties: [
                        // Basic Info
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        // Appearance
                        { name: 'color', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'icon', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        // Settings
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 4, order: 6 } } } },
                        { name: 'isDefault', layout: { positions: { lg: { colSpan: 4, order: 7 } } } },
                        { name: 'order', layout: { positions: { lg: { colSpan: 4, order: 8 } } } },
                    ],
                },
                update: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'appearance' },
                        { id: 'settings' },
                    ],
                    properties: [
                        // Basic Info
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        // Appearance
                        { name: 'color', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'icon', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        // Settings
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 4, order: 6 } } } },
                        { name: 'isDefault', layout: { positions: { lg: { colSpan: 4, order: 7 } } } },
                        { name: 'order', layout: { positions: { lg: { colSpan: 4, order: 8 } } } },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [
                        { id: 'basic-info' },
                        { id: 'appearance' },
                        { id: 'settings' },
                    ],
                    properties: [
                        // Basic Info
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        // Appearance
                        { name: 'color', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'icon', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        // Settings
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 4, order: 6 } } } },
                        { name: 'isDefault', layout: { positions: { lg: { colSpan: 4, order: 7 } } } },
                        { name: 'order', layout: { positions: { lg: { colSpan: 4, order: 8 } } } },
                    ],
                    actions: [
                        ...entityMasterRecordActions()
                    ],
                },
                list: {
                    actions: [
                        ...entityMasterCrudActions(),
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'order', dir: 'asc' }]
                        }),
                    ],
                },
            },
        },
        //#endregion
    };
    return entityDef;
}

var calendarEventType_entity = /*#__PURE__*/Object.freeze({
    __proto__: null,
    calendarEventTypeFactory: calendarEventTypeFactory
});

async function calendarEventFactory(injector) {
    const dataService = injector.get(AXMCalendarEventService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.calendarEvent.name,
        title: RootConfig.entities.calendarEvent.title,
        icon: RootConfig.entities.calendarEvent.icon,
        formats: {
            individual: RootConfig.entities.calendarEvent.title,
            plural: RootConfig.entities.calendarEvent.titlePlural,
            searchResult: {
                title: '{{ title }} - {{ date }}',
                description: '{{ calendar.title }} - {{ type }}',
            },
        },
        //#region ----   Property Groups   ----
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
            {
                id: 'date',
                title: '@general:terms.datetime.date',
            },
            {
                id: 'appearance',
                title: '@general:terms.interface.appearance',
            },
            {
                id: 'settings',
                title: '@general:terms.interface.settings',
            },
        ],
        //#endregion
        //#region ----   Properties   ----
        properties: [
            // Basic Information
            {
                name: 'calendarId',
                title: '@calendar-management:calendar-event.calendar',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsCatalog.lookup,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.calendar.name}`,
                            expose: [
                                { source: 'id', target: 'calendar.id' },
                                { source: 'title', target: 'calendar.title' },
                            ],
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'Enter event title',
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.largeText,
                        options: {
                            rows: 3,
                            placeholder: 'Enter event description',
                        },
                    },
                },
            },
            {
                name: 'typeId',
                title: '@calendar-management:calendar-event.type',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsCatalog.lookup,
                        options: {
                            look: 'select',
                            entity: `${RootConfig.module.name}.${RootConfig.entities.calendarEventType.name}`,
                            expose: [
                                { source: 'id', target: 'type.id' },
                                { source: 'title', target: 'type.title' },
                                { source: 'color', target: 'type.color' },
                                { source: 'icon', target: 'type.icon' },
                            ],
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            // Date & Time
            {
                name: 'date',
                title: '@general:terms.datetime.date',
                groupId: 'date',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'date',
                    interface: {
                        type: AXPWidgetsCatalog.dateTime,
                        options: {
                            showTime: false,
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            // Recurrence
            {
                name: 'isRecurring',
                title: '@calendar-management:calendar-event.is-recurring',
                groupId: 'date',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    defaultValue: false,
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
            {
                name: 'recurrenceRule',
                title: '@calendar-management:calendar-event.recurrence-rule',
                groupId: 'date',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.largeText,
                        options: {
                            rows: 3,
                            placeholder: 'FREQ=YEARLY;BYMONTH=3;BYMONTHDAY=21',
                            visibility: '{{ context.eval("isRecurring") ?? false }}'
                        },
                    },
                },
            },
            // Settings
            {
                name: 'isActive',
                title: '@general:terms.status.states.is-active',
                groupId: 'settings',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
            {
                name: 'order',
                title: '@general:terms.classification.order',
                groupId: 'settings',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsCatalog.number,
                        options: {
                            minValue: 0,
                            maxValue: 9999,
                        },
                    },
                },
            },
        ],
        //#endregion
        //#region ----   Table Columns   ----
        columns: [
            { name: 'title' },
            { name: 'typeId', options: { dataPath: 'type.title' } },
            { name: 'date' },
            { name: 'isRecurring' },
            { name: 'isActive' },
        ],
        //#endregion
        //#region ----   Commands   ----
        commands: {
            create: {
                execute: async (data) => {
                    const res = await dataService.insertOne(data);
                    return { id: res };
                },
            },
            delete: {
                execute: async (id) => {
                    return await dataService.deleteOne(id);
                },
            },
            update: {
                execute: async (data) => {
                    return await dataService.updateOne(data.id, data);
                },
            },
        },
        //#endregion
        //#region ----   Queries   ----
        queries: {
            byKey: {
                execute: async (id) => {
                    return await dataService.getOne(id);
                },
                type: AXPEntityQueryType.Single,
            },
            list: {
                execute: async (e) => {
                    return await dataService.query(e);
                },
                type: AXPEntityQueryType.List,
            },
        },
        //#endregion
        //#region ----   Interface Layouts   ----
        interfaces: {
            master: {
                create: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'date' },
                        { id: 'settings' },
                    ],
                    properties: [
                        // Basic Info
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'typeId', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                        // Date 
                        { name: 'date', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'isRecurring', layout: { positions: { lg: { colSpan: 6, order: 9 } } } },
                        { name: 'recurrenceRule', layout: { positions: { lg: { colSpan: 12, order: 10 } } } },
                        // Settings
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 6, order: 12 } } } },
                        { name: 'order', layout: { positions: { lg: { colSpan: 6, order: 13 } } } },
                    ],
                },
                update: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'date' },
                        { id: 'settings' },
                    ],
                    properties: [
                        // Basic Info
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'typeId', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                        // Date 
                        { name: 'date', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'isRecurring', layout: { positions: { lg: { colSpan: 6, order: 9 } } } },
                        { name: 'recurrenceRule', layout: { positions: { lg: { colSpan: 12, order: 10 } } } },
                        // Settings
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 6, order: 12 } } } },
                        { name: 'order', layout: { positions: { lg: { colSpan: 6, order: 13 } } } },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [
                        { id: 'basic-info' },
                        { id: 'date' },
                        { id: 'settings' },
                    ],
                    properties: [
                        // Basic Info
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'typeId', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                        // Date 
                        { name: 'date', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'isRecurring', layout: { positions: { lg: { colSpan: 6, order: 9 } } } },
                        { name: 'recurrenceRule', layout: { positions: { lg: { colSpan: 12, order: 10 } } } },
                        // Settings
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 6, order: 12 } } } },
                        { name: 'order', layout: { positions: { lg: { colSpan: 6, order: 13 } } } },
                    ],
                    actions: [
                        {
                            title: '@general:actions.edit.title',
                            command: 'quick-modify-entity',
                            priority: 'primary',
                            type: 'update',
                            scope: AXPEntityCommandScope.Individual,
                        },
                        {
                            title: '@general:actions.delete.title',
                            command: 'delete-entity',
                            priority: 'secondary',
                            type: 'delete',
                            scope: AXPEntityCommandScope.Individual,
                        },
                    ],
                },
                list: {
                    actions: [
                        ...entityDetailsCrudActions('calendarId')
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'date', dir: 'asc' }]
                        }),
                    ],
                },
            },
        },
        //#endregion
    };
    return entityDef;
}

var calendarEvent_entity = /*#__PURE__*/Object.freeze({
    __proto__: null,
    calendarEventFactory: calendarEventFactory
});

async function calendarFactory(injector) {
    const dataService = injector.get(AXMCalendarService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.calendar.name,
        title: RootConfig.entities.calendar.title,
        icon: RootConfig.entities.calendar.icon,
        formats: {
            individual: RootConfig.entities.calendar.title,
            plural: RootConfig.entities.calendar.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ calendarType.title }}',
            },
        },
        //#region ----   Related Entities   ----
        relatedEntities: [
            {
                entity: `${RootConfig.module.name}.${RootConfig.entities.calendarEvent.name}`,
                title: RootConfig.entities.calendarEvent.titlePlural,
                columns: ['date', 'typeId', 'title', 'isRecurring', 'isActive'],
                conditions: [
                    entityDetailsSimpleCondition('calendarId')
                ],
            },
        ],
        //#endregion
        //#region ----   Property Groups   ----
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
            {
                id: 'inheritance',
                title: '@calendar-management:calendar.inheritance',
            },
            {
                id: 'week-config',
                title: '@calendar-management:calendar.week-configuration',
            },
            {
                id: 'working-hours',
                title: '@calendar-management:calendar.working-hours',
            },
            {
                id: 'settings',
                title: '@general:terms.interface.settings',
            },
        ],
        //#endregion
        //#region ----   Properties   ----
        properties: [
            // Basic Information
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'Enter calendar title',
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.largeText,
                        options: {
                            rows: 3,
                            placeholder: 'Enter calendar description',
                        },
                    },
                },
            },
            {
                name: 'calendarTypeId',
                title: '@calendar-management:calendar.calendar-type',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'value',
                            textField: 'text',
                            multiple: false,
                            dataSource: [
                                { value: 'gregorian', text: 'Gregorian' },
                                { value: 'solar-hijri', text: 'Solar Hijri' },
                            ],
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            // Inheritance
            {
                name: 'parentId',
                title: '@calendar-management:calendar.parent-calendar',
                groupId: 'inheritance',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsCatalog.lookup,
                        options: {
                            look: 'select',
                            entity: `${RootConfig.module.name}.${RootConfig.entities.calendar.name}`,
                            expose: [
                                { source: 'id', target: 'parent.id' },
                                { source: 'title', target: 'parent.title' },
                            ],
                        },
                    },
                },
            },
            // Week Configuration
            {
                name: 'weekends',
                title: '@calendar-management:calendar.weekend-pattern',
                groupId: 'week-config',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'id',
                            textField: 'title',
                            multiple: true,
                            dataSource: [
                                { id: 'sunday', title: 'Sunday' },
                                { id: 'monday', title: 'Monday' },
                                { id: 'tuesday', title: 'Tuesday' },
                                { id: 'wednesday', title: 'Wednesday' },
                                { id: 'thursday', title: 'Thursday' },
                                { id: 'friday', title: 'Friday' },
                                { id: 'saturday', title: 'Saturday' },
                            ],
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            {
                name: 'firstDayOfWeek',
                title: '@calendar-management:calendar.first-day-of-week',
                groupId: 'week-config',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'id',
                            textField: 'title',
                            multiple: false,
                            dataSource: [
                                { id: 'sunday', title: 'Sunday' },
                                { id: 'monday', title: 'Monday' },
                                { id: 'tuesday', title: 'Tuesday' },
                                { id: 'wednesday', title: 'Wednesday' },
                                { id: 'thursday', title: 'Thursday' },
                                { id: 'friday', title: 'Friday' },
                                { id: 'saturday', title: 'Saturday' },
                            ],
                        },
                    },
                },
                validations: [
                    { rule: 'required' },
                ],
            },
            // // Working Hours
            // {
            //     name: 'workingHours',
            //     title: '@calendar-management:calendar.working-hours-config',
            //     groupId: 'working-hours',
            //     options: {
            //         sort: { enabled: false },
            //         filter: {
            //             advance: { enabled: false },
            //             inline: { enabled: false },
            //         },
            //     },
            //     schema: {
            //         dataType: 'string',
            //         interface: {
            //             type: AXPWidgetsCatalog.flexLayout,
            //             options: {
            //                 rows: 5,
            //                 placeholder: 'JSON configuration for working hours',
            //             },
            //             children:[
            //                 {
            //                 }
            //             ]
            //         },
            //     },
            // },
            // Settings
            {
                name: 'isActive',
                title: '@general:terms.status.states.is-active',
                groupId: 'settings',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
            {
                name: 'isTemplate',
                title: '@calendar-management:calendar.is-template',
                groupId: 'settings',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
            {
                name: 'order',
                title: '@general:terms.classification.order',
                groupId: 'settings',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsCatalog.number,
                        options: {
                            minValue: 0,
                            maxValue: 9999,
                        },
                    },
                },
            },
        ],
        //#endregion
        //#region ----   Table Columns   ----
        columns: [
            { name: 'title' },
            { name: 'calendarTypeId', options: { dataPath: 'calendarType.title' } },
            { name: 'parentId', options: { dataPath: 'parent.title' } },
            { name: 'scopeType' },
            { name: 'isTemplate' },
            { name: 'isActive' },
        ],
        //#region ----   Commands   ----
        commands: {
            create: {
                execute: async (data) => {
                    const res = await dataService.insertOne(data);
                    return { id: res };
                },
            },
            delete: {
                execute: async (id) => {
                    return await dataService.deleteOne(id);
                },
            },
            update: {
                execute: async (data) => {
                    return await dataService.updateOne(data.id, data);
                },
            },
        },
        //#region ----   Queries   ----
        queries: {
            byKey: {
                execute: async (id) => {
                    return await dataService.getOne(id);
                },
                type: AXPEntityQueryType.Single,
            },
            list: {
                execute: async (e) => {
                    return await dataService.query(e);
                },
                type: AXPEntityQueryType.List,
            },
        },
        //#endregion
        //#region ----   Interface Layouts   ----
        interfaces: {
            master: {
                create: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'inheritance' },
                        { id: 'week-config' },
                        { id: 'working-hours' },
                        { id: 'settings' },
                    ],
                    properties: [
                        // Basic Info
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'calendarTypeId', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                        // Inheritance
                        { name: 'parentId', layout: { positions: { lg: { colSpan: 12, order: 5 } } } },
                        // Week Config
                        { name: 'weekends', layout: { positions: { lg: { colSpan: 12, order: 8 } } } },
                        { name: 'firstDayOfWeek', layout: { positions: { lg: { colSpan: 12, order: 9 } } } },
                        // Working Hours
                        //{ name: 'workingHours', layout: { positions: { lg: { colSpan: 12, order: 9 } } } },
                        // Settings
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 4, order: 10 } } } },
                        { name: 'isTemplate', layout: { positions: { lg: { colSpan: 4, order: 11 } } } },
                        { name: 'order', layout: { positions: { lg: { colSpan: 4, order: 12 } } } },
                    ],
                },
                update: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'inheritance' },
                        { id: 'week-config' },
                        { id: 'working-hours' },
                        { id: 'settings' },
                    ],
                    properties: [
                        // Basic Info
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'calendarTypeId', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                        // Inheritance
                        { name: 'parentId', layout: { positions: { lg: { colSpan: 12, order: 5 } } } },
                        // Week Config
                        { name: 'weekends', layout: { positions: { lg: { colSpan: 12, order: 8 } } } },
                        { name: 'firstDayOfWeek', layout: { positions: { lg: { colSpan: 12, order: 9 } } } },
                        // Working Hours
                        //{ name: 'workingHours', layout: { positions: { lg: { colSpan: 12, order: 9 } } } },
                        // Settings
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 4, order: 10 } } } },
                        { name: 'isTemplate', layout: { positions: { lg: { colSpan: 4, order: 11 } } } },
                        { name: 'order', layout: { positions: { lg: { colSpan: 4, order: 12 } } } },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [
                        { id: 'basic-info' },
                        { id: 'inheritance' },
                        { id: 'week-config' },
                        { id: 'working-hours' },
                        { id: 'settings' },
                    ],
                    properties: [
                        // Basic Info
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'calendarTypeId', layout: { positions: { lg: { colSpan: 6, order: 3 } } }, dataPath: 'calendarType.title' },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                        // Inheritance
                        { name: 'parentId', layout: { positions: { lg: { colSpan: 12, order: 5 } } } },
                        // Week Config
                        { name: 'weekends', layout: { positions: { lg: { colSpan: 12, order: 8 } } } },
                        { name: 'firstDayOfWeek', layout: { positions: { lg: { colSpan: 12, order: 9 } } } },
                        // Working Hours
                        //{ name: 'workingHours', layout: { positions: { lg: { colSpan: 12, order: 9 } } } },
                        // Settings
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 4, order: 10 } } } },
                        { name: 'isTemplate', layout: { positions: { lg: { colSpan: 4, order: 11 } } } },
                        { name: 'order', layout: { positions: { lg: { colSpan: 4, order: 12 } } } },
                    ],
                    actions: [
                        entityMasterDeleteAction()
                    ],
                },
                list: {
                    actions: [
                        ...entityMasterCrudActions()
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'title', dir: 'asc' }]
                        }),
                    ],
                },
            },
        },
        //#endregion    
    };
    return entityDef;
}

var calendar_entity = /*#__PURE__*/Object.freeze({
    __proto__: null,
    calendarFactory: calendarFactory
});

class AXMCalendarManagementService {
    constructor() {
        this.calendarEventService = inject(AXMCalendarEventService);
        this.calendarEventTypeService = inject(AXMCalendarEventTypeService);
    }
    async getEvents(range) {
        const events = await this.calendarEventService.query({
            skip: 0,
            take: 9999,
            filter: {
                logic: 'and',
                filters: [
                    { field: 'date', operator: { type: 'lte' }, value: range.end },
                    { field: 'date', operator: { type: 'gte' }, value: range.from },
                ],
            },
        });
        return events.items.map((event) => ({
            date: event.date,
            title: event.title,
            description: event.description,
            type: {
                color: event.type?.color,
                icon: event.type?.icon,
                isHoliday: event.type?.isHoliday,
            },
        }));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMCalendarManagementService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

// Main Module

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

export { AXMCalendarEventService, AXMCalendarEventServiceImpl, AXMCalendarEventTypeService, AXMCalendarEventTypeServiceImpl, AXMCalendarManagementEntityProvider, AXMCalendarManagementMenuProvider, AXMCalendarManagementModule, AXMCalendarManagementPermissionDefinitionProvider, AXMCalendarManagementSearchCommandProvider, AXMCalendarManagementService, AXMCalendarService, AXMCalendarServiceImpl, RootConfig, calendarEventFactory, calendarEventTypeFactory, calendarFactory };
//# sourceMappingURL=acorex-modules-calendar-management.mjs.map
