import * as i0 from '@angular/core';
import { inject, Injectable, signal, Component, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import * as i1$1 from '@acorex/platform/core';
import { AXPPlatformScope, objectKeyValueTransforms, AXPComponentSlotModule, AXP_MODULE_MANIFEST_PROVIDER, AXP_DATASOURCE_DEFINITION_PROVIDER } from '@acorex/platform/core';
import { AXPEntityService, AXP_ENTITY_DEFINITION_LOADER, entityMasterCrudActions, entityMasterRecordActions, entityDetailsCreateActions, entityDetailsSimpleCondition } from '@acorex/platform/layout/entity';
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 { AXPRegionalSetting, AXPSettingsService, AXPSearchCommandProvider, AXP_MENU_PROVIDER, AXP_SETTING_DEFINITION_PROVIDER, AXP_SEARCH_PROVIDER, createAllQueryView, AXPEntityCommandScope } from '@acorex/platform/common';
export { AXPRegionalSetting } from '@acorex/platform/common';
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';
import { AXTranslationService } from '@acorex/core/translation';
import { AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex/platform/auth';
import { AXPCommonMenuKeys, AXPWidgetsList } from '@acorex/modules/common';
import { AXFormatService } from '@acorex/core/format';
import { AXDataSource } from '@acorex/cdk/common';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';

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

//#region ----   Imports   ----
//#endregion
//#region ----   Manifest Definition   ----
/**
 * Locale Management Module Manifest.
 * Defines module metadata, features, and provider references.
 */
const LocaleManagementManifest = {
    name: RootConfig.module.name,
    version: '1.0.0',
    title: RootConfig.module.title,
    icon: RootConfig.module.icon,
    i18n: RootConfig.config.i18n,
    required: true,
    // Module dependencies (optional)
};
//#endregion

// Regional Store - Manages regional settings and system changes
const AXPRegionalStoreService = signalStore({ providedIn: 'root' }, 
// Initial State
withState(() => {
    // Initialize with safe defaults - actual values will be loaded via loadSetting()
    const state = {
        profile: null,
        language: null,
        calendar: null,
    };
    return state;
}), 
// Computed Signals
// withComputed(({ }) => ({
// })),
// Methods for State Management
withMethods((store, settingsService = inject(AXPSettingsService), 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) {
                settingsService.scope(AXPPlatformScope.User).set(AXPRegionalSetting.LocaleProfile, profile.localeInfo.code);
                settingsService.scope(AXPPlatformScope.User).set(AXPRegionalSetting.Language, profile.localeInfo.code);
                patchState(store, { profile: profile.localeInfo.code });
            }
            //
            await applyChanges();
        },
        async loadSetting() {
            const profileCode = (await settingsService.scope(AXPPlatformScope.User).get(AXPRegionalSetting.LocaleProfile)) || 'en-US';
            patchState(store, { profile: profileCode });
            if (profileCode) {
                await localeService.setProfile(profileCode);
            }
            //
            // delay to ensure the profile is set and override the default  
            setTimeout(async () => {
                const calendar = (await settingsService.scope(AXPPlatformScope.User).get(AXPRegionalSetting.Calendar));
                patchState(store, { calendar: calendar });
                calendarService.setActiveCalendar(calendar);
                //
                const language = (await settingsService.scope(AXPPlatformScope.User).get(AXPRegionalSetting.Language));
                patchState(store, { language: language });
                translateService.setActiveLang(language);
                //
                await applyChanges();
            });
            //
        },
    };
}), withHooks((store, settingsService = inject(AXPSettingsService), translateService = inject(AXTranslationService)) => ({
    onInit() {
        settingsService.onChanged.subscribe(async (setting) => {
            const keys = [
                AXPRegionalSetting.LocaleProfile,
                AXPRegionalSetting.Language,
                AXPRegionalSetting.Calendar
            ];
            //
            if (keys.some(k => setting.keys.includes(k))) {
                await store.loadSetting();
            }
        });
    },
    onDestroy() { },
})));

/** Simple cache - timezones are static reference data */
let timezonesCache = null;
class AXMLocaleManagementService {
    constructor() {
        this.entityService = inject(AXPEntityService);
        this.languagesDataAccessor = this.entityService
            .withEntity(RootConfig.module.name, RootConfig.entities.languages.name)
            .data();
        this.timezonesDataAccessor = this.entityService
            .withEntity(RootConfig.module.name, RootConfig.entities.timezones.name)
            .data();
        this.localesDataAccessor = this.entityService
            .withEntity(RootConfig.module.name, RootConfig.entities.locales.name)
            .data();
        this.activeQuery = {
            skip: 0,
            take: 1000,
            filter: {
                logic: 'and',
                filters: [
                    {
                        field: 'isActive',
                        operator: {
                            type: 'equal',
                        },
                        value: true,
                    },
                ],
            },
            sort: [
                {
                    field: 'title',
                    dir: 'asc',
                },
            ],
        };
    }
    async getLocaleProfiles() {
        const { profiles } = await import('./acorex-modules-locale-management-profiles-BmCQxHK5.mjs');
        return profiles;
    }
    async getLanguages() {
        const result = await this.languagesDataAccessor.query(this.activeQuery);
        return result.items.map((c) => ({
            code: c.code,
            title: c.title,
        }));
    }
    async getLocales() {
        const result = await this.localesDataAccessor.query(this.activeQuery);
        return result.items.map((c) => ({
            code: c.code,
            title: c.title,
        }));
    }
    async getAvailableLanguages() {
        return (await this.getLanguages());
    }
    async getTimeZones() {
        if (timezonesCache) {
            return timezonesCache;
        }
        const result = await this.timezonesDataAccessor.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}`;
        };
        timezonesCache = result.items.map((c) => ({
            code: c.code,
            title: `${c.title} (${formatOffset(c.standardOffset)})`,
            offset: c.standardOffset,
            iana: c.code,
            abbr: c.abbreviation,
        }));
        return timezonesCache;
    }
    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.19", ngImport: i0, type: AXMLocaleManagementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

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.19", ngImport: i0, type: AXMLanguageSlotComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.19", 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", "closeParentOnClick", "lockOnLoading"], outputs: ["onItemClick"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", 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.19", ngImport: i0, type: AXMLocaleProfileProviderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleProfileProviderService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleProfileProviderService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

const AXMPermissionsKeys = {
    LocaleManagement: {
        Management: 'LocaleManagement:Permission:Management',
        Language: {
            Management: 'LocaleManagement:Permission:Language.Management',
            View: 'LocaleManagement:Permission:Language.View',
            Edit: 'LocaleManagement:Permission:Language.Edit',
            Delete: 'LocaleManagement:Permission:Language.Delete',
            Create: 'LocaleManagement:Permission:Language.Create',
        },
        Timezone: {
            Management: 'LocaleManagement:Permission:Timezone.Management',
            View: 'LocaleManagement:Permission:Timezone.View',
            Edit: 'LocaleManagement:Permission:Timezone.Edit',
            Delete: 'LocaleManagement:Permission:Timezone.Delete',
            Create: 'LocaleManagement:Permission:Timezone.Create',
        },
    },
};

class AXMLocaleManagementPermissionDefinitionProvider {
    constructor(injector) {
        this.injector = injector;
        this.translateService = this.injector.get(AXTranslationService);
    }
    async define(context) {
        const keys = AXMPermissionsKeys.LocaleManagement;
        const moduleTitle = await this.translateService.translateAsync('@locale-management:module.permissions.title');
        const moduleDescription = await this.translateService.translateAsync('@locale-management:module.permissions.description');
        context.addGroup(RootConfig.module.name, moduleTitle, moduleDescription)
            //
            .addPermission(keys.Language.Management, await this.translateService.translateAsync('@locale-management:languages.permissions.languages.title'), await this.translateService.translateAsync('@locale-management:languages.permissions.languages.description'))
            .addChild(keys.Language.View, await this.translateService.translateAsync('@locale-management:languages.permissions.languages.actions.view.title'), await this.translateService.translateAsync('@locale-management:languages.permissions.languages.actions.view.description'))
            .addChild(keys.Language.Create, await this.translateService.translateAsync('@locale-management:languages.permissions.languages.actions.create.title'), await this.translateService.translateAsync('@locale-management:languages.permissions.languages.actions.create.description'))
            .addChild(keys.Language.Edit, await this.translateService.translateAsync('@locale-management:languages.permissions.languages.actions.edit.title'), await this.translateService.translateAsync('@locale-management:languages.permissions.languages.actions.edit.description'))
            .addChild(keys.Language.Delete, await this.translateService.translateAsync('@locale-management:languages.permissions.languages.actions.delete.title'), await this.translateService.translateAsync('@locale-management:languages.permissions.languages.actions.delete.description'))
            .endPermission()
            //
            .addPermission(keys.Timezone.Management, await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.title'), await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.description'))
            .addChild(keys.Timezone.View, await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.actions.view.title'), await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.actions.view.description'))
            .addChild(keys.Timezone.Create, await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.actions.create.title'), await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.actions.create.description'))
            .addChild(keys.Timezone.Edit, await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.actions.edit.title'), await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.actions.edit.description'))
            .addChild(keys.Timezone.Delete, await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.actions.delete.title'), await this.translateService.translateAsync('@locale-management:timezones.permissions.timezones.actions.delete.description'))
            .endPermission()
            //
            .endGroup();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementPermissionDefinitionProvider, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementPermissionDefinitionProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementPermissionDefinitionProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

const AXPLocaleManagementMenuKeys = {
    Root: 'locale-management:menu',
    Languages: 'locale-management:menu:languages',
    Divider1: 'locale-management:menu:divider-1',
    Timezones: 'locale-management:menu:timezones',
};

class AXMLocaleManagementMenuProvider {
    constructor() {
        this.entityService = inject(AXPEntityService);
    }
    async provide(context) {
        const module = RootConfig.module;
        context.find(AXPCommonMenuKeys.Configuration).addItems([
            {
                name: AXPLocaleManagementMenuKeys.Root,
                priority: 8910,
                text: '@locale-management:module.menus.foundation-group.title',
                icon: module.icon,
                policy: {
                    features: [module.name],
                    permissions: [AXMPermissionsKeys.LocaleManagement.Management],
                },
                children: [
                    {
                        name: AXPLocaleManagementMenuKeys.Languages,
                        text: '@locale-management:languages.menus.languages.title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.languages.name),
                        icon: RootConfig.entities.languages.icon,
                        priority: 1,
                    },
                    {
                        name: AXPLocaleManagementMenuKeys.Divider1,
                        text: '',
                        type: 'break',
                        priority: 2,
                    },
                    {
                        name: AXPLocaleManagementMenuKeys.Timezones,
                        text: '@locale-management:timezones.menus.timezones.title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.timezones.name),
                        icon: RootConfig.entities.timezones.icon,
                        priority: 3,
                    },
                ],
            },
        ]);
    }
}

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);
            }
        }
        return null;
    }
    async list() {
        const m = RootConfig.module.name;
        return Promise.resolve(Object.values(RootConfig.entities).map((e) => ({ name: e.name, module: m })));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementEntityProvider, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementEntityProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementEntityProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

class AXMRegionalSettingProvider {
    constructor(injector) {
        this.injector = injector;
        this.regionalService = this.injector.get(AXMLocaleManagementService);
        this.translateService = this.injector.get(AXTranslationService);
        this.formatService = this.injector.get(AXFormatService);
    }
    async provide(context) {
        const trans = async (key) => await this.translateService.translateAsync(`@locale-management:settings.settings.regional.${key}`);
        const profiles = await this.regionalService.getLocaleProfiles();
        const defaultProfile = profiles.find((p) => p.code === 'en-US');
        context
            .addGroup('regional-settings', await trans('title'), await trans('description'), 'fa-light fa-earth-americas')
            // Date & Time Section
            .addSection('date-time', await trans('datetime.title'), await trans('datetime.description'))
            .addSetting({
            key: AXPRegionalSetting.TimeZone,
            title: await trans('datetime.timezone.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: await this.regionalService.getBrowserTimeZoneCode(),
            valueTransforms: objectKeyValueTransforms('code'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'code',
                    dataSource: 'timezones',
                },
            },
            description: await trans('datetime.timezone.description'),
        })
            .endSection()
            // Region Section
            .addSection('region', await trans('region.title'), await trans('region.description'))
            .addSetting({
            key: AXPRegionalSetting.LocaleProfile,
            title: await trans('region.format.title'),
            scope: 'U',
            isInherited: true,
            defaultValue: defaultProfile.code,
            valueTransforms: objectKeyValueTransforms('code'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'code',
                    dataSource: profiles,
                },
            },
            description: await trans('region.format.description'),
        })
            .addSetting({
            key: AXPRegionalSetting.Language,
            title: await trans('region.language.title'),
            scope: 'U',
            isInherited: true,
            defaultValue: await this.translateService.getDefaultLang(),
            valueTransforms: objectKeyValueTransforms('code'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'code',
                    dataSource: 'locales',
                },
                triggers: [
                    {
                        event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                        action: `{{ widget.setValue(context.eval('${AXPRegionalSetting.LocaleProfile}')) }}`,
                    },
                ],
            },
            description: await trans('region.language.description'),
        })
            .addSetting({
            key: AXPRegionalSetting.Calendar,
            title: await trans('region.calendar.title'),
            scope: 'U',
            isInherited: true,
            defaultValue: defaultProfile.calendar.system,
            valueTransforms: objectKeyValueTransforms('value'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'value',
                    textField: 'text',
                    dataSource: [
                        {
                            text: await trans('region.calendar.options.gregorian'),
                            value: 'gregorian',
                        },
                        {
                            text: await trans('region.calendar.options.hijri'),
                            value: 'solar-hijri',
                        },
                    ],
                },
                triggers: [
                    {
                        event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                        action: [
                            `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').calendar.system) }}`,
                        ],
                    },
                ],
            },
            description: await trans('region.calendar.description'),
        })
            .addSetting({
            key: AXPRegionalSetting.FirstDayOfWeek,
            title: await trans('region.firstday.title'),
            scope: 'T',
            isInherited: false,
            defaultValue: defaultProfile.calendar.week.startsOn,
            valueTransforms: objectKeyValueTransforms('value'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'value',
                    textField: 'text',
                    dataSource: [
                        {
                            text: await trans('region.firstday.options.saturday'),
                            value: 6,
                        },
                        {
                            text: await trans('region.firstday.options.sunday'),
                            value: 0,
                        },
                        {
                            text: await trans('region.firstday.options.monday'),
                            value: 1,
                        },
                    ],
                    triggers: [
                        {
                            event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                            action: [
                                `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').calendar.week.startsOn) }}`,
                            ],
                        },
                    ],
                },
            },
            description: await trans('region.firstday.description'),
        })
            .addSetting({
            key: AXPRegionalSetting.WeekendDays,
            title: await trans('region.workdays.title'),
            scope: 'T',
            isInherited: false,
            defaultValue: defaultProfile.calendar.week.weekends,
            widget: {
                type: AXPWidgetsList.Editors.SelectionList,
                options: {
                    multiple: true,
                    valueField: 'value',
                    textField: 'text',
                    dataSource: [
                        { text: await trans('region.workdays.options.monday'), value: 1 },
                        { text: await trans('region.workdays.options.tuesday'), value: 2 },
                        { text: await trans('region.workdays.options.wednesday'), value: 3 },
                        { text: await trans('region.workdays.options.thursday'), value: 4 },
                        { text: await trans('region.workdays.options.friday'), value: 5 },
                        { text: await trans('region.workdays.options.saturday'), value: 6 },
                        { text: await trans('region.workdays.options.sunday'), value: 0 },
                    ],
                },
                triggers: [
                    {
                        event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                        action: [
                            `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').calendar.week.weekends) }}`,
                        ],
                    },
                ],
            },
            description: await trans('region.workdays.description'),
        })
            // .addSetting({
            //   key: AXPRegionalSetting.ShortDate,
            //   title: await trans('region.shortdate.title'),
            //   scope: 'U',
            //   isInherited: true,
            //   defaultValue: defaultProfile.formats.date.medium,
            //   valueTransforms: objectKeyValueTransforms('value'),
            //   widget: {
            //     type: AXPWidgetsList.Editors.SelectBox,
            //     options: {
            //       valueField: 'value',
            //       textField: 'text',
            //       dataSource: await Promise.all(
            //         profiles.map(async (c) => ({
            //           text: `${c.formats.date.medium} (${await this.formatService.format(new Date(), 'datetime', { format: c.formats.date.medium })})`,
            //           value: c.formats.date.medium,
            //         })),
            //       ),
            //     },
            //     triggers: [
            //       {
            //         event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
            //         action: [
            //           `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').formats.date.short) }}`,
            //         ],
            //       },
            //     ],
            //   },
            //   description: await trans('region.shortdate.description'),
            // })
            // .addSetting({
            //   key: AXPRegionalSetting.LongDate,
            //   title: await trans('region.longdate.title'),
            //   scope: 'U',
            //   isInherited: true,
            //   defaultValue: defaultProfile.formats.date.long,
            //   valueTransforms: objectKeyValueTransforms('value'),
            //   widget: {
            //     type: AXPWidgetsList.Editors.SelectBox,
            //     options: {
            //       valueField: 'value',
            //       textField: 'text',
            //       dataSource: await Promise.all(
            //         profiles.map(async (c) => ({
            //           text: `${c.formats.date.long} (${await this.formatService.format(new Date(), 'datetime', { format: c.formats.date.long })})`,
            //           value: c.formats.date.long,
            //         })),
            //       ),
            //     },
            //     triggers: [
            //       {
            //         event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
            //         action: [
            //           `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').formats.date.long) }}`,
            //         ],
            //       },
            //     ],
            //   },
            //   description: await trans('region.longdate.description'),
            // })
            // .addSetting({
            //   key: AXPRegionalSetting.ShortTime,
            //   title: await trans('region.shorttime.title'),
            //   scope: 'U',
            //   isInherited: true,
            //   defaultValue: defaultProfile.formats.time.short,
            //   valueTransforms: objectKeyValueTransforms('value'),
            //   widget: {
            //     type: AXPWidgetsList.Editors.SelectBox,
            //     options: {
            //       valueField: 'value',
            //       textField: 'text',
            //       dataSource: await Promise.all(
            //         profiles.map(async (c) => ({
            //           text: `${c.formats.time.short} (${await this.formatService.format(new Date(), 'datetime', { format: c.formats.time.short })})`,
            //           value: c.formats.time.short,
            //         })),
            //       ),
            //     },
            //     triggers: [
            //       {
            //         event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
            //         action: [
            //           `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').formats.time.short) }}`,
            //         ],
            //       },
            //     ],
            //   },
            //   description: await trans('region.shorttime.description'),
            // })
            // .addSetting({
            //   key: AXPRegionalSetting.LongTime,
            //   title: await trans('region.longtime.title'),
            //   scope: 'U',
            //   isInherited: true,
            //   defaultValue: defaultProfile.formats.time.long,
            //   valueTransforms: objectKeyValueTransforms('value'),
            //   widget: {
            //     type: AXPWidgetsList.Editors.SelectBox,
            //     options: {
            //       valueField: 'value',
            //       textField: 'text',
            //       dataSource: await Promise.all(
            //         profiles.map(async (c) => ({
            //           text: `${c.formats.time.long} (${await this.formatService.format(new Date(), 'datetime', { format: c.formats.time.long })})`,
            //           value: c.formats.time.long,
            //         })),
            //       ),
            //     },
            //     triggers: [
            //       {
            //         event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
            //         action: [
            //           `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').formats.time.long) }}`,
            //         ],
            //       },
            //     ],
            //   },
            //   description: await trans('region.longtime.description'),
            // })
            .endSection()
            // Unit Settings Section
            .addSection('units', await trans('units.title'), await trans('units.description'))
            .addSetting({
            key: AXPRegionalSetting.TemperatureUnits,
            title: await trans('units.temperature.title'),
            scope: 'U',
            isInherited: true,
            defaultValue: defaultProfile.units.temperature,
            valueTransforms: objectKeyValueTransforms('value'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'value',
                    textField: 'text',
                    dataSource: await Promise.all(profiles.map(async (c) => ({
                        text: await trans(`units.temperature.options.${c.units.temperature}`),
                        value: c.units.temperature,
                    }))),
                },
                triggers: [
                    {
                        event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                        action: [
                            `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').units.temperature) }}`,
                        ],
                    },
                ],
            },
            description: await trans('units.temperature.description'),
        })
            .addSetting({
            key: AXPRegionalSetting.DistanceUnits,
            title: await trans('units.distance.title'),
            scope: 'U',
            isInherited: true,
            defaultValue: defaultProfile.units.distance,
            valueTransforms: objectKeyValueTransforms('value'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'value',
                    textField: 'text',
                    dataSource: await Promise.all(profiles.map(async (c) => ({
                        text: await trans(`units.distance.options.${c.units.distance}`),
                        value: c.units.distance,
                    }))),
                },
                triggers: [
                    {
                        event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                        action: [
                            `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').units.distance) }}`,
                        ],
                    },
                ],
            },
            description: await trans('units.distance.description'),
        })
            .addSetting({
            key: AXPRegionalSetting.WeightUnits,
            title: await trans('units.weight.title'),
            scope: 'U',
            isInherited: true,
            defaultValue: defaultProfile.units.weight,
            valueTransforms: objectKeyValueTransforms('value'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'value',
                    textField: 'text',
                    dataSource: await Promise.all(profiles.map(async (c) => ({
                        text: await trans(`units.weight.options.${c.units.weight}`),
                        value: c.units.weight,
                    }))),
                },
                triggers: [
                    {
                        event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                        action: [
                            `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').units.weight) }}`,
                        ],
                    },
                ],
            },
            description: await trans('units.weight.description'),
        })
            .addSetting({
            key: AXPRegionalSetting.VolumeUnits,
            title: await trans('units.volume.title'),
            scope: 'U',
            isInherited: true,
            defaultValue: defaultProfile.units.volume,
            valueTransforms: objectKeyValueTransforms('value'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'value',
                    textField: 'text',
                    dataSource: [
                        { text: await trans('units.volume.options.liters'), value: 'liters' },
                        { text: await trans('units.volume.options.gallons'), value: 'gallons' },
                    ],
                },
                triggers: [
                    {
                        event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                        action: [
                            `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').units.volume) }}`,
                        ],
                    },
                ],
            },
            description: await trans('units.volume.description'),
        })
            .addSetting({
            key: AXPRegionalSetting.SpeedUnits,
            title: await trans('units.speed.title'),
            scope: 'U',
            isInherited: true,
            defaultValue: defaultProfile.units.speed,
            valueTransforms: objectKeyValueTransforms('value'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'value',
                    textField: 'text',
                    dataSource: await Promise.all(profiles.map(async (c) => ({
                        text: await trans(`units.speed.options.${c.units.speed}`),
                        value: c.units.speed,
                    }))),
                },
                triggers: [
                    {
                        event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                        action: [
                            `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').units.speed) }}`,
                        ],
                    },
                ],
            },
            description: await trans('units.speed.description'),
        })
            .addSetting({
            key: AXPRegionalSetting.AreaUnits,
            title: await trans('units.area.title'),
            scope: 'U',
            isInherited: true,
            defaultValue: defaultProfile.units.area,
            valueTransforms: objectKeyValueTransforms('value'),
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'value',
                    textField: 'text',
                    dataSource: await Promise.all(profiles.map(async (c) => ({
                        text: await trans(`units.area.options.${c.units.area}`),
                        value: c.units.area,
                    }))),
                },
                triggers: [
                    {
                        event: `{{ events.context('${AXPRegionalSetting.LocaleProfile}') }}`,
                        action: [
                            `{{ widget.setValue(widget.find('${AXPRegionalSetting.LocaleProfile}').output('item').units.area) }}`,
                        ],
                    },
                ],
            },
            description: await trans('units.area.description'),
        })
            .endSection()
            .endGroup();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMRegionalSettingProvider, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMRegionalSettingProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMRegionalSettingProvider, 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}`,
                    },
                },
            },
        ];
    }
}

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 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.languages, this.locales];
    }
}

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.19", 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.19", ngImport: i0, type: AXMLocaleManagementModule, imports: [CommonModule, i1$1.AXPComponentSlotModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementModule, providers: [
            // Module-specific providers (not part of manifest system)
            {
                provide: AX_LOCALE_PROFILE_PROVIDERS,
                useClass: AXMLocaleProfileProviderService,
                multi: true,
            },
            // Module Manifest Provider
            {
                provide: AXP_MODULE_MANIFEST_PROVIDER,
                useValue: LocaleManagementManifest,
                multi: true,
            },
            // Provider references (now using tokens)
            {
                provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                useClass: AXMLocaleManagementPermissionDefinitionProvider,
                multi: true,
            },
            {
                provide: AXP_MENU_PROVIDER,
                useClass: AXMLocaleManagementMenuProvider,
                multi: true,
            },
            {
                provide: AXP_ENTITY_DEFINITION_LOADER,
                useClass: AXMLocaleManagementEntityProvider,
                multi: true,
            },
            {
                provide: AXP_SETTING_DEFINITION_PROVIDER,
                useClass: AXMRegionalSettingProvider,
                multi: true,
            },
            {
                provide: AXP_SEARCH_PROVIDER,
                useClass: AXMLocaleManagementSearchCommandProvider,
                multi: true,
            },
            {
                provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                useClass: AXMLocaleManagementDataSourceDefinition,
                multi: true,
            },
        ], imports: [CommonModule,
            AXPComponentSlotModule.forChild({
                'root-header-end': [
                    {
                        name: 'language',
                        component: AXMLanguageSlotComponent
                    }
                ]
            })] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLocaleManagementModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        CommonModule,
                        AXPComponentSlotModule.forChild({
                            'root-header-end': [
                                {
                                    name: 'language',
                                    component: AXMLanguageSlotComponent
                                }
                            ]
                        })
                    ],
                    providers: [
                        // Module-specific providers (not part of manifest system)
                        {
                            provide: AX_LOCALE_PROFILE_PROVIDERS,
                            useClass: AXMLocaleProfileProviderService,
                            multi: true,
                        },
                        // Module Manifest Provider
                        {
                            provide: AXP_MODULE_MANIFEST_PROVIDER,
                            useValue: LocaleManagementManifest,
                            multi: true,
                        },
                        // Provider references (now using tokens)
                        {
                            provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                            useClass: AXMLocaleManagementPermissionDefinitionProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_MENU_PROVIDER,
                            useClass: AXMLocaleManagementMenuProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_ENTITY_DEFINITION_LOADER,
                            useClass: AXMLocaleManagementEntityProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SETTING_DEFINITION_PROVIDER,
                            useClass: AXMRegionalSettingProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SEARCH_PROVIDER,
                            useClass: AXMLocaleManagementSearchCommandProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                            useClass: AXMLocaleManagementDataSourceDefinition,
                            multi: true,
                        },
                    ],
                }]
        }], ctorParameters: () => [{ type: i1$1.AXPAppStartUpService }, { type: i0.Injector }] });

async function languagesFactory(injector) {
    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.entities.language.fields.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.entities.language.fields.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 } },
        ],
        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
});

async function localesFactory(injector) {
    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' },
            { name: 'default' },
        ],
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
        ],
        properties: [
            {
                name: 'languageId',
                title: '@locale-management:locales.entities.locale.fields.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.entities.locale.fields.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',
                    },
                ],
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '250px', order: 2 } },
            { name: 'countryCode', options: { width: '100px', order: 3 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }],
                    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 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }],
                    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 } } } },
                    ],
                },
                single: {
                    title: RootConfig.entities.locales.title,
                    sections: [{ id: 'basic-info' }],
                    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: 'title', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

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

async function timezonesFactory(injector) {
    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.entities.timezone.fields.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.entities.timezone.fields.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.entities.timezone.fields.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.entities.timezone.fields.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 } },
        ],
        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
});

// Entity Types

/**
 * @deprecated Use AXPRegionalSetting from @acorex/platform/common instead.
 * This file is kept for backward compatibility but will be removed in a future version.
 *
 * The enum has been moved to platform/common to avoid circular dependencies.
 * Platform libraries should import from @acorex/platform/common.
 * Module implementations can continue to import from here for now.
 */

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

export { AXMLocaleManagementEntityProvider, AXMLocaleManagementMenuProvider, AXMLocaleManagementModule, AXMLocaleManagementPermissionDefinitionProvider, AXMLocaleManagementSearchCommandProvider, AXMLocaleManagementService, AXMLocaleProfileProviderService, RootConfig, languagesFactory, localesFactory, timezonesFactory };
//# sourceMappingURL=acorex-modules-locale-management.mjs.map
