import * as i0 from '@angular/core';
import { Injectable, inject, NgModule, signal, Component, Injector } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AXPSearchCommandProvider, createAllQueryView, AXPEntityQueryType, AXPEntityCommandScope, AXPSettingService, AXP_MENU_PROVIDER, AXP_SEARCH_PROVIDER, AXP_SETTING_DEFINITION_PROVIDER } from '@acorex/platform/common';
import { AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex/platform/auth';
import { AXPEntityService, AXMEntityCrudServiceImpl, entityMasterCrudActions, entityMasterRecordActions, entityDetailsCreateActions, entityDetailsSimpleCondition, AXP_ENTITY_DEFINITION_LOADER } from '@acorex/platform/layout/entity';
import { AXTranslationService } from '@acorex/core/translation';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { AXDataSource, convertArrayToDataSource } from '@acorex/cdk/common';
import * as i1$1 from '@acorex/platform/core';
import { AXPPlatformScope, AXP_DATASOURCE_DEFINITION_PROVIDER } from '@acorex/platform/core';
import * as i2$1 from '@acorex/platform/layout/components';
import { AXPComponentSlotModule } from '@acorex/platform/layout/components';
import * as i3 from '@acorex/components/button';
import { AXButtonModule } from '@acorex/components/button';
import * as i2 from '@acorex/components/decorators';
import { AXDecoratorModule } from '@acorex/components/decorators';
import * as i1 from '@acorex/components/dropdown';
import { AXDropdownModule } from '@acorex/components/dropdown';
import { AXPopoverModule } from '@acorex/components/popover';
import { signalStore, withState, withMethods, patchState, withHooks } from '@ngrx/signals';
import { AXCalendarService } from '@acorex/core/date-time';
import { AXLocaleService, AX_LOCALE_PROFILE_PROVIDERS } from '@acorex/core/locale';

const config = {
    i18n: 'locale-management',
};
const RootConfig = {
    config,
    module: {
        name: 'LocaleManagement',
        title: '@locale-management:module-name',
        icon: 'fa-light fa-globe',
    },
    entities: {
        languages: {
            name: 'Languages',
            title: '@locale-management:languages.individual-title',
            titlePlural: '@locale-management:languages.plural-title',
            icon: 'fa-light fa-language',
        },
        locales: {
            name: 'Locales',
            title: '@locale-management:locales.individual-title',
            titlePlural: '@locale-management:locales.plural-title',
            icon: 'fa-light fa-globe',
        },
        timezones: {
            name: 'Timezones',
            title: '@locale-management:timezones.individual-title',
            titlePlural: '@locale-management:timezones.plural-title',
            icon: 'fa-light fa-clock',
        },
        currencies: {
            name: 'Currencies',
            title: '@locale-management:currencies.individual-title',
            titlePlural: '@locale-management:currencies.plural-title',
            icon: 'fa-light fa-coins',
        },
    },
};

class AXMLocaleManagementEntityProvider {
    constructor(injector) {
        this.injector = injector;
    }
    async get(moduleName, entityName) {
        if (moduleName == RootConfig.module.name) {
            switch (entityName) {
                case RootConfig.entities.languages.name:
                    return (await Promise.resolve().then(function () { return languages_entity; })).languagesFactory(this.injector);
                case RootConfig.entities.locales.name:
                    return (await Promise.resolve().then(function () { return locales_entity; })).localesFactory(this.injector);
                case RootConfig.entities.timezones.name:
                    return (await Promise.resolve().then(function () { return timezones_entity; })).timezonesFactory(this.injector);
                case RootConfig.entities.currencies.name:
                    return (await Promise.resolve().then(function () { return currencies_entity; })).currenciesFactory(this.injector);
            }
        }
        return null;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementEntityProvider, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementEntityProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementEntityProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

const AXPLocaleManagementMenuKeys = {
    Root: 'locale-management:menu',
    Languages: 'locale-management:menu:languages',
    Timezones: 'locale-management:menu:timezones',
    Currencies: 'locale-management:menu:currencies',
};

class AXMLocaleManagementMenuProvider {
    constructor() {
        this.entityService = inject(AXPEntityService);
    }
    async provide(context) {
        const module = RootConfig.module;
        context.addItems([
            {
                name: AXPLocaleManagementMenuKeys.Root,
                priority: 9004,
                text: '@locale-management:module-name',
                icon: module.icon,
                data: {
                    requiredPermission: [
                        'platform'
                    ],
                },
                children: [
                    {
                        name: AXPLocaleManagementMenuKeys.Languages,
                        text: '@locale-management:languages.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.languages.name),
                        icon: RootConfig.entities.languages.icon,
                        priority: 1,
                    },
                    {
                        name: 'locale-management:menu:divider-1',
                        text: '',
                        type: 'break',
                        priority: 2,
                    },
                    {
                        name: AXPLocaleManagementMenuKeys.Timezones,
                        text: '@locale-management:timezones.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.timezones.name),
                        icon: RootConfig.entities.timezones.icon,
                        priority: 3,
                    },
                    {
                        name: AXPLocaleManagementMenuKeys.Currencies,
                        text: '@locale-management:currencies.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.currencies.name),
                        icon: RootConfig.entities.currencies.icon,
                        priority: 4,
                    },
                ],
            },
        ]);
    }
}

class AXMLocaleManagementPermissionDefinitionProvider {
    constructor(injector) {
        this.injector = injector;
        this.translateService = this.injector.get(AXTranslationService);
    }
    async define(context) {
        const trans = async (key) => await this.translateService.translateAsync(`permissions.locale-management.${key}`, {
            scope: 'locale-management',
        });
        context
            .addGroup('locale-management', 'Locale Management')
            .addPermission('locale.management', 'Manage Locale Data')
            .addChild('languages.view', 'View Languages')
            .addChild('languages.create', 'Create Languages')
            .addChild('languages.update', 'Update Languages')
            .addChild('languages.delete', 'Delete Languages')
            .addChild('locales.view', 'View Locales')
            .addChild('locales.create', 'Create Locales')
            .addChild('locales.update', 'Update Locales')
            .addChild('locales.delete', 'Delete Locales')
            .addChild('timezones.view', 'View Timezones')
            .addChild('timezones.create', 'Create Timezones')
            .addChild('timezones.update', 'Update Timezones')
            .addChild('timezones.delete', 'Delete Timezones')
            .addChild('currencies.view', 'View Currencies')
            .addChild('currencies.create', 'Create Currencies')
            .addChild('currencies.update', 'Update Currencies')
            .addChild('currencies.delete', 'Delete Currencies')
            .endPermission()
            .endGroup();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementPermissionDefinitionProvider, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementPermissionDefinitionProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementPermissionDefinitionProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

class AXMLocaleManagementSearchCommandProvider extends AXPSearchCommandProvider {
    constructor() {
        super(...arguments);
        this.commands = [
            {
                group: 'entity',
                title: 'New Language',
                icon: RootConfig.entities.languages.icon,
                description: 'Create a new language with locales.',
                command: {
                    name: 'create-entity',
                    options: {
                        entity: `${RootConfig.module.name}.${RootConfig.entities.languages.name}`,
                    },
                },
            },
            {
                group: 'entity',
                title: 'New Timezone',
                icon: RootConfig.entities.timezones.icon,
                description: 'Create a new timezone definition.',
                command: {
                    name: 'create-entity',
                    options: {
                        entity: `${RootConfig.module.name}.${RootConfig.entities.timezones.name}`,
                    },
                },
            },
            {
                group: 'entity',
                title: 'New Currency',
                icon: RootConfig.entities.currencies.icon,
                description: 'Create a new currency definition.',
                command: {
                    name: 'create-entity',
                    options: {
                        entity: `${RootConfig.module.name}.${RootConfig.entities.currencies.name}`,
                    },
                },
            },
        ];
    }
}

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

async function languagesFactory(injector) {
    const dataService = injector.get(AXMLanguagesService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.languages.name,
        title: RootConfig.entities.languages.title,
        icon: RootConfig.entities.languages.icon,
        formats: {
            individual: RootConfig.entities.languages.title,
            plural: RootConfig.entities.languages.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ nativeTitle }}',
            },
        },
        relatedEntities: [
            {
                entity: `${RootConfig.module.name}.${RootConfig.entities.locales.name}`,
                title: RootConfig.entities.locales.title,
                columns: ['code', 'title', 'countryCode', 'isDefault', 'isActive'],
                conditions: [
                    entityDetailsSimpleCondition('languageId')
                ],
                actions: [
                    entityDetailsCreateActions('languageId'),
                ],
            },
        ],
        plugins: [
            { name: 'archive' },
        ],
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
            {
                id: 'settings',
                title: '@general:terms.interface.settings',
            },
        ],
        properties: [
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'e.g., en, es, fr',
                        },
                    },
                },
                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: 'e.g., English, Spanish',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'nativeTitle',
                title: '@locale-management:languages.native-title',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'e.g., English, Español',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'isRTL',
                title: '@locale-management:languages.is-rtl',
                groupId: 'settings',
                options: {
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '100px', order: 1 } },
            { name: 'title', options: { width: '200px', order: 2 } },
            { name: 'nativeTitle', options: { width: '200px', order: 3 } },
            { name: 'isRTL', options: { width: '80px', order: 4 } },
        ],
        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);
                },
            },
        },
        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,
            },
        },
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'nativeTitle', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'isRTL', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'nativeTitle', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'isRTL', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                    ],
                },
                single: {
                    title: RootConfig.entities.languages.title,
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'nativeTitle', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'isRTL', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                    ],
                    actions: [
                        ...entityMasterRecordActions(),
                    ],
                },
                list: {
                    actions: [
                        ...entityMasterCrudActions(),
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'title', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

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

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

async function localesFactory(injector) {
    const dataService = injector.get(AXMLocalesService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.locales.name,
        title: RootConfig.entities.locales.title,
        formats: {
            individual: RootConfig.entities.locales.title,
            plural: RootConfig.entities.locales.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }}',
            },
        },
        plugins: [
            { name: 'archive' },
        ],
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
            {
                id: 'settings',
                title: '@general:terms.interface.settings',
            },
        ],
        properties: [
            {
                name: 'languageId',
                title: '@locale-management:locales.language',
                groupId: 'basic-info',
                options: {
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsCatalog.lookup,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.languages.name}`,
                            expose: [
                                { source: 'id', target: 'language.id' },
                                { source: 'title', target: 'language.title' }
                            ]
                        }
                    }
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'e.g., en-US, es-MX',
                        },
                    },
                },
                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: 'e.g., English (United States)',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'countryCode',
                title: '@locale-management:locales.country-code',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'e.g., US, MX',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'isDefault',
                title: '@locale-management:locales.is-default',
                groupId: 'settings',
                options: {
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '250px', order: 2 } },
            { name: 'countryCode', options: { width: '100px', order: 3 } },
            { name: 'isDefault', options: { width: '80px', order: 4 } },
        ],
        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);
                },
            },
        },
        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,
            },
        },
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        // NOTE: languageId is NOT included here - it's passed via context
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'countryCode', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'isDefault', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        // NOTE: languageId is NOT included here - it's immutable in update
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'countryCode', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'isDefault', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                    ],
                },
                single: {
                    title: RootConfig.entities.locales.title,
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    actions: [
                        ...entityMasterRecordActions(),
                        {
                            title: '@general:actions.edit.title',
                            command: 'quick-modify-entity',
                            priority: 'primary',
                            type: 'update',
                            scope: AXPEntityCommandScope.Individual,
                        },
                    ],
                },
                list: {
                    actions: [
                        ...entityMasterCrudActions(),
                        {
                            title: '@general:actions.edit.title',
                            command: 'quick-modify-entity',
                            priority: 'secondary',
                            type: 'update',
                            scope: AXPEntityCommandScope.Individual,
                        },
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'isDefault', dir: 'desc' }, { name: 'title', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

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

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

async function timezonesFactory(injector) {
    const dataService = injector.get(AXMTimezonesService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.timezones.name,
        title: RootConfig.entities.timezones.title,
        icon: RootConfig.entities.timezones.icon,
        formats: {
            individual: RootConfig.entities.timezones.title,
            plural: RootConfig.entities.timezones.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }}',
            },
        },
        plugins: [
            { name: 'archive' },
        ],
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
            {
                id: 'settings',
                title: '@general:terms.interface.settings',
            },
        ],
        properties: [
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'e.g., America/New_York',
                        },
                    },
                },
                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: 'e.g., Eastern Standard Time',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'abbreviation',
                title: '@locale-management:timezones.abbreviation',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'e.g., EST, PST',
                        },
                    },
                },
            },
            {
                name: 'standardOffset',
                title: '@locale-management:timezones.standard-offset',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsCatalog.number,
                        options: {
                            placeholder: 'Offset in minutes from UTC',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'region',
                title: '@locale-management:timezones.region',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'e.g., Americas, Europe',
                        },
                    },
                },
            },
            {
                name: 'supportsDST',
                title: '@locale-management:timezones.supports-dst',
                groupId: 'settings',
                options: {
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '200px', order: 1 } },
            { name: 'title', options: { width: '250px', order: 2 } },
            { name: 'abbreviation', options: { width: '100px', order: 3 } },
            { name: 'standardOffset', options: { width: '120px', order: 4 } },
            { name: 'supportsDST', options: { width: '80px', order: 5 } },
        ],
        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);
                },
            },
        },
        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,
            },
        },
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'abbreviation', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'standardOffset', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'region', layout: { positions: { lg: { colSpan: 12, order: 5 } } } },
                        { name: 'supportsDST', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'abbreviation', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'standardOffset', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'region', layout: { positions: { lg: { colSpan: 12, order: 5 } } } },
                        { name: 'supportsDST', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                    ],
                },
                single: {
                    title: RootConfig.entities.timezones.title,
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'abbreviation', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'standardOffset', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'region', layout: { positions: { lg: { colSpan: 12, order: 5 } } } },
                        { name: 'supportsDST', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                    ],
                    actions: [
                        ...entityMasterRecordActions(),
                    ],
                },
                list: {
                    actions: [
                        ...entityMasterCrudActions(),
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'region', dir: 'asc' }, { name: 'title', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

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

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

async function currenciesFactory(injector) {
    const dataService = injector.get(AXMCurrenciesService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.currencies.name,
        title: RootConfig.entities.currencies.title,
        icon: RootConfig.entities.currencies.icon,
        formats: {
            individual: RootConfig.entities.currencies.title,
            plural: RootConfig.entities.currencies.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }} ({{ symbol }})',
            },
        },
        plugins: [
            { name: 'archive' },
        ],
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
            {
                id: 'settings',
                title: '@general:terms.interface.settings',
            },
        ],
        properties: [
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'e.g., USD, EUR, IRR',
                        },
                    },
                },
                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: 'e.g., US Dollar, Euro',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'symbol',
                title: '@locale-management:currencies.symbol',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'e.g., $, €, ﷼',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'decimalPlaces',
                title: '@locale-management:currencies.decimal-places',
                groupId: 'basic-info',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsCatalog.number,
                        options: {
                            minValue: 0,
                            maxValue: 4,
                            placeholder: 'Usually 2',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
        ],
        columns: [
            { name: 'code', options: { width: '100px', order: 1 } },
            { name: 'title', options: { width: '250px', order: 2 } },
            { name: 'symbol', options: { width: '80px', order: 3 } },
            { name: 'decimalPlaces', options: { width: '120px', order: 4 } },
        ],
        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);
                },
            },
        },
        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,
            },
        },
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'symbol', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'decimalPlaces', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'symbol', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'decimalPlaces', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                    ],
                },
                single: {
                    title: RootConfig.entities.currencies.title,
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'symbol', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'decimalPlaces', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                    ],
                    actions: [
                        ...entityMasterRecordActions(),
                    ],
                },
                list: {
                    actions: [
                        ...entityMasterCrudActions(),
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'title', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

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

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

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

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

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

// Entity Services

class AXMLocaleManagementService {
    constructor() {
        this.currenciesService = inject(AXMCurrenciesService);
        this.languagesService = inject(AXMLanguagesService);
        this.timezonesService = inject(AXMTimezonesService);
        this.localesService = inject(AXMLocalesService);
        this.activeQuery = {
            skip: 0,
            take: 1000,
            filter: {
                logic: 'and',
                filters: [
                    {
                        field: 'isActive',
                        operator: {
                            type: 'equal',
                        },
                        value: true
                    }
                ]
            },
            sort: [
                {
                    field: 'title',
                    dir: 'asc',
                }
            ]
        };
    }
    async getCurrencies() {
        const result = await this.currenciesService.query(this.activeQuery);
        return result.items.map(c => ({
            code: c.code,
            title: c.title,
            symbol: c.symbol,
            format: c.symbol,
        }));
    }
    async getLocaleProfiles() {
        const { profiles } = await import('./acorex-modules-locale-management-profiles-BmCQxHK5.mjs');
        return profiles;
    }
    async getLanguages() {
        const result = await this.languagesService.query(this.activeQuery);
        return result.items.map(c => ({
            code: c.code,
            title: c.title,
        }));
    }
    async getLocales() {
        const result = await this.localesService.query(this.activeQuery);
        return result.items.map(c => ({
            code: c.code,
            title: c.title,
        }));
    }
    async getAvailableLanguages() {
        return (await this.getLanguages());
    }
    async getTimeZones() {
        const result = await this.timezonesService.query({ ...this.activeQuery, sort: [{ field: 'standardOffset', dir: 'asc' }] });
        const padZero = (value) => value.toString().padStart(2, '0');
        const formatOffset = (offset) => {
            const sign = offset > 0 ? '+' : '-';
            const hours = padZero(Math.floor(Math.abs(offset) / 60));
            const minutes = padZero(Math.abs(offset % 60));
            return `${sign}${hours}:${minutes}`;
        };
        return result.items.map(c => ({
            code: c.code,
            title: `${c.title} (${formatOffset(c.standardOffset)})`,
            offset: c.standardOffset,
            iana: c.code,
            abbr: c.abbreviation,
        }));
    }
    async getBrowserTimeZoneCode() {
        const timeZones = await this.getTimeZones();
        const now = new Date();
        // Calculate offset in hours and minutes
        const offsetMinutes = now.getTimezoneOffset() * -1;
        // Find matching time zone
        const matchedZone = timeZones.find((zone) => zone.offset === offsetMinutes);
        return matchedZone ? matchedZone.code : 'UTC';
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

class AXMLocaleManagementDataSourceDefinition {
    constructor() {
        this.localeManagementService = inject(AXMLocaleManagementService);
        //#region Country
        this.timezones = {
            name: 'timezones',
            title: 'Timezones',
            columns: [
                {
                    name: 'code',
                    title: 'Code',
                    type: 'string',
                    datatype: 'string',
                },
                {
                    name: 'title',
                    title: 'Title',
                    type: 'string',
                    datatype: 'string',
                },
            ],
            filters: [],
            textField: { name: 'title', title: 'Title' },
            valueField: { name: 'code', title: 'Code' },
            samples: [
                { code: 'GMT-5', title: 'Eastern Time (US & Canada)' },
                { code: 'GMT+0', title: 'Greenwich Mean Time' },
                { code: 'GMT+1', title: 'Central European Time' },
            ],
            source: () => {
                return new AXDataSource({
                    pageSize: 50,
                    key: 'code',
                    load: async (e) => {
                        const items = await this.localeManagementService.getTimeZones();
                        return {
                            items: items,
                            total: items.length,
                        };
                    },
                    byKey: async (key) => {
                        const items = await this.localeManagementService.getTimeZones();
                        return items.find((t) => t.code == key);
                    },
                });
            },
        };
        //#endregion
        //#region Currencies
        this.currencies = {
            name: 'currencies',
            title: 'Currencies',
            columns: [
                {
                    name: 'code',
                    title: 'Code',
                    type: 'string',
                    datatype: 'string',
                },
                {
                    name: 'title',
                    title: 'Title',
                    type: 'string',
                    datatype: 'string',
                },
            ],
            filters: [],
            textField: { name: 'title', title: 'Title' },
            valueField: { name: 'code', title: 'Code' },
            samples: [
                { code: 'USD', title: 'United States Dollar' },
                { code: 'CAD', title: 'Canadian Dollar' },
                { code: 'GBP', title: 'British Pound' },
            ],
            source: () => {
                return new AXDataSource({
                    load: async (e) => {
                        const items = await this.localeManagementService.getCurrencies();
                        return {
                            items: items,
                            total: items.length,
                        };
                    },
                    pageSize: 50,
                    key: 'code',
                    byKey: async (key) => {
                        const items = await this.localeManagementService.getCurrencies();
                        return items.find((c) => c.code == key);
                    },
                });
            },
        };
        this.booleans = {
            name: 'booleans',
            title: 'Booleans',
            columns: [
                {
                    name: 'value',
                    title: 'Value',
                    type: 'string',
                    datatype: 'string',
                },
                {
                    name: 'title',
                    title: 'Title',
                    type: 'string',
                    datatype: 'string',
                },
            ],
            filters: [],
            textField: { name: 'title', title: 'Title' },
            valueField: { name: 'value', title: 'Value' },
            samples: [
                { value: 'true', title: 'Yes' },
                { value: 'false', title: 'No' },
            ],
            source: () => {
                return convertArrayToDataSource([
                    { value: 'true', title: 'Yes' },
                    { value: 'false', title: 'No' },
                ]);
            },
        };
        //#region Languages
        this.languages = {
            name: 'languages',
            title: 'Languages',
            columns: [
                {
                    name: 'code',
                    title: 'Code',
                    type: 'string',
                    datatype: 'string',
                },
                {
                    name: 'title',
                    title: 'Title',
                    type: 'string',
                    datatype: 'string',
                },
            ],
            filters: [],
            textField: { name: 'title', title: 'Title' },
            valueField: { name: 'code', title: 'Code' },
            samples: [
                { code: 'en', title: 'English' },
                { code: 'fa', title: 'Persian' },
            ],
            source: () => {
                return new AXDataSource({
                    load: async (e) => {
                        const items = await this.localeManagementService.getLanguages();
                        return {
                            items: items,
                            total: items.length,
                        };
                    },
                    pageSize: 50,
                    key: 'code',
                    byKey: async (key) => {
                        const items = await this.localeManagementService.getLanguages();
                        return items.find((l) => l.code == key);
                    },
                });
            },
        };
        //#endregion
        //#region Locales
        this.locales = {
            name: 'locales',
            title: 'Locales',
            columns: [
                {
                    name: 'code',
                    title: 'Code',
                    type: 'string',
                    datatype: 'string',
                },
                {
                    name: 'title',
                    title: 'Title',
                    type: 'string',
                    datatype: 'string',
                },
            ],
            filters: [],
            textField: { name: 'title', title: 'Title' },
            valueField: { name: 'code', title: 'Code' },
            samples: [
                { code: 'en-US', title: 'English (United States)' },
                { code: 'fa-IR', title: 'Persian (Iran)' },
            ],
            source: () => {
                return new AXDataSource({
                    load: async (e) => {
                        const items = await this.localeManagementService.getLocales();
                        return {
                            items: items,
                            total: items.length,
                        };
                    },
                    pageSize: 50,
                    key: 'code',
                    byKey: async (key) => {
                        const items = await this.localeManagementService.getLocales();
                        const result = items.find((c) => c.code == key);
                        return result;
                    },
                });
            },
        };
    }
    //#endregion
    async items() {
        return [this.timezones, this.currencies, this.languages, this.locales, this.booleans];
    }
}

const path = 'regional:';
var AXPRegionalSetting;
(function (AXPRegionalSetting) {
    AXPRegionalSetting["LocaleProfile"] = "regional:locale-profile";
    AXPRegionalSetting["TimeZone"] = "regional:timezone";
    AXPRegionalSetting["Language"] = "regional:language";
    AXPRegionalSetting["Country"] = "regional:country";
    AXPRegionalSetting["Calendar"] = "regional:calendar";
    AXPRegionalSetting["FirstDayOfWeek"] = "regional:first-day-of-week";
    AXPRegionalSetting["WeekendDays"] = "regional:weekend-days";
    AXPRegionalSetting["ShortDate"] = "regional:short-date";
    AXPRegionalSetting["MediumDate"] = "regional:medium-date";
    AXPRegionalSetting["LongDate"] = "regional:long-date";
    AXPRegionalSetting["ShortTime"] = "regional:short-time";
    AXPRegionalSetting["MediumTime"] = "regional:medium-time";
    AXPRegionalSetting["LongTime"] = "regional:long-time";
    AXPRegionalSetting["MeasurementUnits"] = "regional:measurement-units";
    AXPRegionalSetting["TemperatureUnits"] = "regional:temperature-units";
    AXPRegionalSetting["DistanceUnits"] = "regional:distance-units";
    AXPRegionalSetting["WeightUnits"] = "regional:weight-units";
    AXPRegionalSetting["VolumeUnits"] = "regional:volume-units";
    AXPRegionalSetting["SpeedUnits"] = "regional:speed-units";
    AXPRegionalSetting["AreaUnits"] = "regional:area-units";
})(AXPRegionalSetting || (AXPRegionalSetting = {}));

// Regional Store - Manages regional settings and system changes
const AXPRegionalStoreService = signalStore({ providedIn: 'root' }, 
// Initial State
withState((localeService = inject(AXLocaleService)) => {
    const state = {
        profile: localeService.activeProfile().localeInfo.code,
        language: localeService.activeProfile().localeInfo.language,
        calendar: localeService.activeProfile().calendar.system,
    };
    return state;
}), 
// Computed Signals
// withComputed(({ }) => ({
// })),
// Methods for State Management
withMethods((store, settingService = inject(AXPSettingService), localeService = inject(AXLocaleService), calendarService = inject(AXCalendarService), translateService = inject(AXTranslationService)) => {
    const applyChanges = async () => {
        const profile = localeService.activeProfile();
        const html = document.getElementsByTagName('html')[0];
        profile.i18nMeta?.rtl ? html.setAttribute('dir', 'rtl') : html.removeAttribute('dir');
    };
    return {
        async changeProfile(profileCode) {
            await localeService.setProfile(profileCode);
            const profile = localeService.activeProfile();
            //
            if (store.profile() != profile.localeInfo.code) {
                settingService.scope(AXPPlatformScope.User).set(AXPRegionalSetting.LocaleProfile, profile.localeInfo.code);
                settingService.scope(AXPPlatformScope.User).set(AXPRegionalSetting.Language, profile.localeInfo.code);
                patchState(store, { profile: profile.localeInfo.code });
            }
            //
            await applyChanges();
        },
        async loadSetting() {
            const profileCode = (await settingService.scope(AXPPlatformScope.User).get(AXPRegionalSetting.LocaleProfile));
            patchState(store, { profile: profileCode });
            await localeService.setProfile(profileCode);
            //
            // delay to ensure the profile is set and override the default  
            setTimeout(async () => {
                const calendar = (await settingService.scope(AXPPlatformScope.User).get(AXPRegionalSetting.Calendar));
                patchState(store, { calendar: calendar });
                calendarService.setActiveCalendar(calendar);
                //
                const language = (await settingService.scope(AXPPlatformScope.User).get(AXPRegionalSetting.Language));
                patchState(store, { language: language });
                translateService.setActiveLang(language);
                //
                await applyChanges();
            });
            //
        },
    };
}), withHooks((store, settingService = inject(AXPSettingService), translateService = inject(AXTranslationService)) => ({
    onInit() {
        settingService.onChanged.subscribe(async (setting) => {
            const keys = [
                AXPRegionalSetting.LocaleProfile,
                AXPRegionalSetting.Language,
                AXPRegionalSetting.Calendar
            ];
            //
            if (keys.some(k => setting.keys.includes(k))) {
                await store.loadSetting();
            }
        });
    },
    onDestroy() { },
})));

class AXMLanguageSlotComponent {
    constructor() {
        this.localeManagementService = inject(AXMLocaleManagementService);
        this.store = inject(AXPRegionalStoreService);
        this.items = signal([], ...(ngDevMode ? [{ debugName: "items" }] : []));
    }
    async ngOnInit() {
        const items = await this.localeManagementService.getLocaleProfiles();
        this.items.set(items);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLanguageSlotComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.4", type: AXMLanguageSlotComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: "<ax-button color=\"primary\">\n  <ax-icon class=\"fa-regular fa-globe\"> </ax-icon>\n  <ax-dropdown-panel>\n    <ax-button-item-list>\n      @for(lang of items(); track lang){\n      <ax-button-item\n        [text]=\"lang.title\"\n        [selected]=\"store.profile() === lang.code\"\n        (onClick)=\"store.changeProfile(lang.code)\"\n      >\n        <ax-prefix>\n          <ax-icon icon=\"fa-solid fa-flag\"> </ax-icon>\n        </ax-prefix>\n      </ax-button-item>\n      }\n    </ax-button-item-list>\n  </ax-dropdown-panel>\n</ax-button>\n", dependencies: [{ kind: "ngmodule", type: AXDropdownModule }, { kind: "component", type: i1.AXDropdownPanelComponent, selector: "ax-dropdown-panel", inputs: ["isOpen", "fitParent", "dropdownWidth", "position", "placement", "_target", "adaptivityEnabled"], outputs: ["onOpened", "onClosed"] }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "component", type: i2.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }, { kind: "component", type: i2.AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "ngmodule", type: AXPopoverModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i3.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: "component", type: i3.AXButtonItemComponent, selector: "ax-button-item", inputs: ["color", "disabled", "text", "selected", "divided", "data", "name"], outputs: ["onClick", "onFocus", "onBlur", "disabledChange"] }, { kind: "component", type: i3.AXButtonItemListComponent, selector: "ax-button-item-list", inputs: ["items"], outputs: ["onItemClick"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLanguageSlotComponent, decorators: [{
            type: Component,
            args: [{ imports: [AXDropdownModule, AXDecoratorModule, AXPopoverModule, AXButtonModule], template: "<ax-button color=\"primary\">\n  <ax-icon class=\"fa-regular fa-globe\"> </ax-icon>\n  <ax-dropdown-panel>\n    <ax-button-item-list>\n      @for(lang of items(); track lang){\n      <ax-button-item\n        [text]=\"lang.title\"\n        [selected]=\"store.profile() === lang.code\"\n        (onClick)=\"store.changeProfile(lang.code)\"\n      >\n        <ax-prefix>\n          <ax-icon icon=\"fa-solid fa-flag\"> </ax-icon>\n        </ax-prefix>\n      </ax-button-item>\n      }\n    </ax-button-item-list>\n  </ax-dropdown-panel>\n</ax-button>\n" }]
        }] });

/**
 * Custom locale profile provider that integrates with the locale-management module
 * to provide profiles from the platform's data instead of the default UI library profiles
 */
class AXMLocaleProfileProviderService {
    constructor() {
        this.localeManagementService = inject(AXMLocaleManagementService);
    }
    /**
     * Provides locale profiles from the locale-management module
     * This allows the platform to override the default UI library profiles
     */
    async provide() {
        try {
            // Get profiles from the locale-management module
            const profiles = await this.localeManagementService.getLocaleProfiles();
            // Convert to the format expected by the UI library
            const result = {};
            for (const profile of profiles) {
                try {
                    // Convert AXPLocaleProfile to AXLocaleProfile (remove platform-specific properties)
                    const coreProfile = {
                        localeInfo: profile.localeInfo,
                        calendar: profile.calendar,
                        formats: profile.formats,
                        units: profile.units,
                        i18nMeta: profile.i18nMeta,
                    };
                    // Validate that the profile has all required properties
                    if (this.isValidProfile(coreProfile)) {
                        // Store the profile with lazy loading for better performance
                        result[profile.code] = () => Promise.resolve(coreProfile);
                    }
                    else {
                        console.warn(`[AXMLocaleProfileProviderService] Profile ${profile.code} is missing required properties, skipping`);
                    }
                }
                catch (profileError) {
                    console.error(`[AXMLocaleProfileProviderService] Error processing profile ${profile.code}:`, profileError);
                }
            }
            if (Object.keys(result).length === 0) {
                console.warn('[AXMLocaleProfileProviderService] No valid profiles found, falling back to default behavior');
            }
            else {
                console.log(`[AXMLocaleProfileProviderService] Successfully loaded ${Object.keys(result).length} profiles:`, Object.keys(result));
            }
            return result;
        }
        catch (error) {
            console.error('[AXMLocaleProfileProviderService] Failed to load profiles:', error);
            // Fallback to empty result if loading fails
            return {};
        }
    }
    /**
     * Validates that a profile has all required properties
     */
    isValidProfile(profile) {
        return (profile &&
            profile.localeInfo &&
            profile.calendar &&
            profile.formats &&
            profile.units &&
            typeof profile.localeInfo.code === 'string' &&
            typeof profile.localeInfo.language === 'string');
    }
    /**
     * Gets the list of available locale codes from the locale-management module
     * This can be used by other services to check available locales
     */
    async getAvailableLocaleCodes() {
        try {
            const profiles = await this.localeManagementService.getLocaleProfiles();
            return profiles.map(p => p.code);
        }
        catch (error) {
            console.error('[AXMLocaleProfileProviderService] Failed to get available locale codes:', error);
            return [];
        }
    }
    /**
     * Checks if a specific locale is available
     */
    async hasLocale(localeCode) {
        try {
            const codes = await this.getAvailableLocaleCodes();
            return codes.includes(localeCode);
        }
        catch (error) {
            console.error(`[AXMLocaleProfileProviderService] Failed to check locale ${localeCode}:`, error);
            return false;
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleProfileProviderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleProfileProviderService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleProfileProviderService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

class AXMLocaleManagementModule {
    constructor(appInitService, injector) {
        const service = injector.get(AXPRegionalStoreService);
        appInitService.registerTask({
            name: 'Settings',
            statusText: 'Apply Regional Settings ...',
            priority: 5,
            run: async () => {
                await service.loadSetting();
            }
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementModule, deps: [{ token: i1$1.AXPAppStartUpService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementModule, imports: [CommonModule,
            // Entity Modules
            AXMLanguagesEntityModule,
            AXMLocalesEntityModule,
            AXMTimezonesEntityModule,
            AXMCurrenciesEntityModule, i2$1.AXPComponentSlotModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementModule, providers: [
            // Locale Profile Provider Integration
            {
                provide: AX_LOCALE_PROFILE_PROVIDERS,
                useClass: AXMLocaleProfileProviderService,
                multi: true,
            },
            // Module Providers
            {
                provide: AXP_ENTITY_DEFINITION_LOADER,
                useClass: AXMLocaleManagementEntityProvider,
                multi: true,
            },
            {
                provide: AXP_MENU_PROVIDER,
                useClass: AXMLocaleManagementMenuProvider,
                multi: true,
            },
            {
                provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                useClass: AXMLocaleManagementPermissionDefinitionProvider,
                multi: true,
            },
            {
                provide: AXP_SEARCH_PROVIDER,
                useClass: AXMLocaleManagementSearchCommandProvider,
                multi: true,
            },
            {
                provide: AXP_SETTING_DEFINITION_PROVIDER,
                useFactory: async () => {
                    const injector = inject(Injector);
                    const provider = (await import('./acorex-modules-locale-management-settings.provider-Cy0NOzzw.mjs')).AXMRegionalSettingProvider;
                    return new provider(injector);
                },
                multi: true
            },
            {
                provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                useClass: AXMLocaleManagementDataSourceDefinition,
                multi: true,
            },
        ], imports: [CommonModule,
            // Entity Modules
            AXMLanguagesEntityModule,
            AXMLocalesEntityModule,
            AXMTimezonesEntityModule,
            AXMCurrenciesEntityModule,
            AXPComponentSlotModule.forChild({
                'root-header-end': [
                    {
                        name: 'language',
                        component: AXMLanguageSlotComponent
                    }
                ]
            })] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLocaleManagementModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        CommonModule,
                        // Entity Modules
                        AXMLanguagesEntityModule,
                        AXMLocalesEntityModule,
                        AXMTimezonesEntityModule,
                        AXMCurrenciesEntityModule,
                        AXPComponentSlotModule.forChild({
                            'root-header-end': [
                                {
                                    name: 'language',
                                    component: AXMLanguageSlotComponent
                                }
                            ]
                        })
                    ],
                    providers: [
                        // Locale Profile Provider Integration
                        {
                            provide: AX_LOCALE_PROFILE_PROVIDERS,
                            useClass: AXMLocaleProfileProviderService,
                            multi: true,
                        },
                        // Module Providers
                        {
                            provide: AXP_ENTITY_DEFINITION_LOADER,
                            useClass: AXMLocaleManagementEntityProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_MENU_PROVIDER,
                            useClass: AXMLocaleManagementMenuProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                            useClass: AXMLocaleManagementPermissionDefinitionProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SEARCH_PROVIDER,
                            useClass: AXMLocaleManagementSearchCommandProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SETTING_DEFINITION_PROVIDER,
                            useFactory: async () => {
                                const injector = inject(Injector);
                                const provider = (await import('./acorex-modules-locale-management-settings.provider-Cy0NOzzw.mjs')).AXMRegionalSettingProvider;
                                return new provider(injector);
                            },
                            multi: true
                        },
                        {
                            provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                            useClass: AXMLocaleManagementDataSourceDefinition,
                            multi: true,
                        },
                    ],
                }]
        }], ctorParameters: () => [{ type: i1$1.AXPAppStartUpService }, { type: i0.Injector }] });

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

export { AXMCurrenciesEntityModule, AXMCurrenciesService, AXMCurrenciesServiceImpl, AXMLanguagesEntityModule, AXMLanguagesService, AXMLanguagesServiceImpl, AXMLocaleManagementEntityProvider, AXMLocaleManagementMenuProvider, AXMLocaleManagementModule, AXMLocaleManagementPermissionDefinitionProvider, AXMLocaleManagementSearchCommandProvider, AXMLocaleManagementService, AXMLocaleProfileProviderService, AXMLocalesEntityModule, AXMLocalesService, AXMLocalesServiceImpl, AXMTimezonesEntityModule, AXMTimezonesService, AXMTimezonesServiceImpl, AXPRegionalSetting, RootConfig, currenciesFactory, languagesFactory, localesFactory, timezonesFactory };
//# sourceMappingURL=acorex-modules-locale-management.mjs.map
