import { AXP_MODULE_MANIFEST_PROVIDER } from '@acorex/platform/core';
import { AXPEntityService, AXMEntityCrudServiceImpl, AXP_ENTITY_DEFINITION_LOADER } from '@acorex/platform/layout/entity';
import * as i0 from '@angular/core';
import { inject, Injector, Injectable, NgModule } from '@angular/core';
import { AXPSearchCommandProvider, createAllQueryView, createQueryView, AXPEntityCommandScope, AXP_MENU_PROVIDER, AXP_SETTING_DEFINITION_PROVIDER, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
import { AXPCommonMenuKeys, AXPWidgetsList } from '@acorex/modules/common';

const config = {
    i18n: 'system-insight',
};
const RootConfig = {
    config,
    module: {
        route: 'system-insight',
        module: 'system-insight',
        name: 'SystemInsight',
        title: '@system-insight:module.title',
        icon: 'fa-light fa-monitor-waveform',
    },
    entities: {
        auditLog: {
            name: 'AuditLog',
            title: '@system-insight:logs.entities.audit-log.title',
            titlePlural: '@system-insight:logs.entities.audit-log.plural',
            icon: 'fa-light fa-file-code',
        },
    },
};

//#region ----   Imports   ----
//#endregion
//#region ----   Manifest Definition   ----
/**
 * System Insight Module Manifest.
 * Defines module metadata, features, and provider references.
 */
const SystemInsightManifest = {
    name: RootConfig.module.name,
    version: '1.0.0',
    title: RootConfig.module.title,
    icon: RootConfig.module.icon,
    i18n: RootConfig.config.i18n,
    // Module dependencies
    dependencies: ['ReportManagement'],
};
//#endregion

const AXMSystemInsightMenuKeys = {
    Root: 'SystemInsight:Menu',
    AuditLog: 'SystemInsight:Menu:AuditLog',
};

//#region ----   Imports   ----
//#endregion
//#region ----   Menu Provider   ----
class AXMSystemInsightMenuProvider {
    constructor() {
        this.entityService = inject(AXPEntityService);
    }
    async provide(context) {
        const module = RootConfig.module;
        context.find(AXPCommonMenuKeys.Administration).addItems([
            {
                name: AXMSystemInsightMenuKeys.Root,
                priority: 3,
                text: module.title,
                icon: module.icon,
                type: 'menu',
                policy: {
                    features: [module.name],
                },
                children: [
                    {
                        name: AXMSystemInsightMenuKeys.AuditLog,
                        text: RootConfig.entities.auditLog.titlePlural,
                        path: this.entityService.createPath(module.name, RootConfig.entities.auditLog.name),
                        icon: RootConfig.entities.auditLog.icon,
                        priority: 1,
                    },
                ],
            },
        ]);
    }
}
//#endregion

class AXMSystemInsightEntityProvider {
    constructor() {
        this.injector = inject(Injector);
    }
    preload() {
        const moduleName = RootConfig.module.name;
        return Array.from(Object.values(RootConfig.entities)).map((entity) => ({
            module: moduleName,
            entity: entity.name,
        }));
    }
    async get(moduleName, entityName) {
        if (moduleName !== RootConfig.module.name) {
            return null;
        }
        switch (entityName) {
            case RootConfig.entities.auditLog.name:
                return (await Promise.resolve().then(function () { return auditLog_entity; })).auditLogFactory(this.injector);
            default:
                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: AXMSystemInsightEntityProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMSystemInsightEntityProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMSystemInsightEntityProvider, decorators: [{
            type: Injectable
        }] });

var AXPSystemInsightSettings;
(function (AXPSystemInsightSettings) {
    //#region ----   Retention Settings   ----
    AXPSystemInsightSettings["RetentionEnabled"] = "SystemInsight:Setting:Retention.Enabled";
    AXPSystemInsightSettings["RetentionPeriod"] = "SystemInsight:Setting:Retention.Period";
    //#endregion
    //#region ----   Storage Settings   ----
    AXPSystemInsightSettings["StorageLocation"] = "SystemInsight:Setting:Storage.Location";
    AXPSystemInsightSettings["StorageFormat"] = "SystemInsight:Setting:Storage.Format";
    AXPSystemInsightSettings["MaxFileSize"] = "SystemInsight:Setting:Storage.MaxFileSize";
    AXPSystemInsightSettings["CompressionEnabled"] = "SystemInsight:Setting:Storage.CompressionEnabled";
    //#endregion
    //#region ----   Log Level Settings   ----
    AXPSystemInsightSettings["DefaultLogLevel"] = "SystemInsight:Setting:Level.Default";
    AXPSystemInsightSettings["ModuleLogLevels"] = "SystemInsight:Setting:Level.Modules";
    //#endregion
    //#region ----   Alert Settings   ----
    AXPSystemInsightSettings["AlertEnabled"] = "SystemInsight:Setting:Alert.Enabled";
    AXPSystemInsightSettings["AlertLogLevel"] = "SystemInsight:Setting:Alert.Level";
    AXPSystemInsightSettings["AlertEmail"] = "SystemInsight:Setting:Alert.Email";
    //#endregion
    //#region ----   Performance Settings   ----
    AXPSystemInsightSettings["AsyncLogging"] = "SystemInsight:Setting:Performance.AsyncEnabled";
    AXPSystemInsightSettings["BatchSize"] = "SystemInsight:Setting:Performance.BatchSize";
    AXPSystemInsightSettings["FlushInterval"] = "SystemInsight:Setting:Performance.FlushInterval";
    //#endregion
})(AXPSystemInsightSettings || (AXPSystemInsightSettings = {}));

/**
 * Provides configuration definitions for the System Insight module.
 * Covers retention policies, storage, log levels, alerting, and performance tuning.
 */
class AXPSystemInsightSettingProvider {
    async provide(context) {
        const retentionVisibility = `{{ context.eval('${AXPSystemInsightSettings.RetentionEnabled}') }}`;
        const alertVisibility = `{{ context.eval('${AXPSystemInsightSettings.AlertEnabled}') }}`;
        const asyncVisibility = `{{ context.eval('${AXPSystemInsightSettings.AsyncLogging}') }}`;
        context
            .addGroup('system-insight', '@system-insight:logs.settings.group.title', '@system-insight:logs.settings.group.description', 'fa-light fa-file-lines')
            //#region ----   Retention   ----
            .addSection('retention', '@system-insight:logs.settings.retention.title', '@system-insight:logs.settings.retention.description')
            .addSetting({
            key: AXPSystemInsightSettings.RetentionEnabled,
            title: '@system-insight:logs.settings.retention.items.enabled.title',
            description: '@system-insight:logs.settings.retention.items.enabled.description',
            scope: 'T',
            isInherited: true,
            defaultValue: true,
            widget: {
                type: AXPWidgetsList.Editors.ToggleSwitch,
            },
        })
            .addSetting({
            key: AXPSystemInsightSettings.RetentionPeriod,
            title: '@system-insight:logs.settings.retention.items.period.title',
            description: '@system-insight:logs.settings.retention.items.period.description',
            scope: 'T',
            isInherited: true,
            defaultValue: 30,
            widget: {
                type: AXPWidgetsList.Editors.NumberBox,
                options: {
                    minValue: 1,
                    maxValue: 365,
                    visibility: retentionVisibility,
                },
            },
            validationRules: [{ rule: 'required' }],
        })
            .endSection()
            //#endregion
            //#region ----   Storage   ----
            .addSection('storage', '@system-insight:logs.settings.storage.title', '@system-insight:logs.settings.storage.description')
            .addSetting({
            key: AXPSystemInsightSettings.StorageLocation,
            title: '@system-insight:logs.settings.storage.items.location.title',
            description: '@system-insight:logs.settings.storage.items.location.description',
            scope: 'T',
            isInherited: false,
            defaultValue: '/var/log/acorex',
            widget: {
                type: AXPWidgetsList.Editors.TextBox,
                options: {
                    placeholder: '@system-insight:logs.settings.storage.items.location.placeholder',
                },
            },
            validationRules: [{ rule: 'required' }],
        })
            .addSetting({
            key: AXPSystemInsightSettings.StorageFormat,
            title: '@system-insight:logs.settings.storage.items.format.title',
            description: '@system-insight:logs.settings.storage.items.format.description',
            scope: 'T',
            isInherited: true,
            defaultValue: 'json',
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'id',
                    textField: 'title',
                    dataSource: [
                        { id: 'json', title: '@system-insight:logs.settings.storage.items.format.options.json' },
                        { id: 'text', title: '@system-insight:logs.settings.storage.items.format.options.text' },
                        { id: 'csv', title: '@system-insight:logs.settings.storage.items.format.options.csv' },
                    ],
                },
            },
        })
            .addSetting({
            key: AXPSystemInsightSettings.MaxFileSize,
            title: '@system-insight:logs.settings.storage.items.max-size.title',
            description: '@system-insight:logs.settings.storage.items.max-size.description',
            scope: 'T',
            isInherited: true,
            defaultValue: 10,
            widget: {
                type: AXPWidgetsList.Editors.NumberBox,
                options: {
                    minValue: 1,
                    maxValue: 1000,
                    suffix: 'MB',
                },
            },
        })
            .addSetting({
            key: AXPSystemInsightSettings.CompressionEnabled,
            title: '@system-insight:logs.settings.storage.items.compression.title',
            description: '@system-insight:logs.settings.storage.items.compression.description',
            scope: 'T',
            isInherited: true,
            defaultValue: true,
            widget: {
                type: AXPWidgetsList.Editors.ToggleSwitch,
            },
        })
            .endSection()
            //#endregion
            //#region ----   Log Level   ----
            .addSection('level', '@system-insight:logs.settings.level.title', '@system-insight:logs.settings.level.description')
            .addSetting({
            key: AXPSystemInsightSettings.DefaultLogLevel,
            title: '@system-insight:logs.settings.level.items.default.title',
            description: '@system-insight:logs.settings.level.items.default.description',
            scope: 'T',
            isInherited: true,
            defaultValue: 'info',
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'id',
                    textField: 'title',
                    dataSource: [
                        { id: 'error', title: '@system-insight:logs.settings.level.items.default.options.error' },
                        { id: 'warn', title: '@system-insight:logs.settings.level.items.default.options.warn' },
                        { id: 'info', title: '@system-insight:logs.settings.level.items.default.options.info' },
                        { id: 'debug', title: '@system-insight:logs.settings.level.items.default.options.debug' },
                        { id: 'trace', title: '@system-insight:logs.settings.level.items.default.options.trace' },
                    ],
                },
            },
        })
            .endSection()
            //#endregion
            //#region ----   Alerting   ----
            .addSection('alert', '@system-insight:logs.settings.alert.title', '@system-insight:logs.settings.alert.description')
            .addSetting({
            key: AXPSystemInsightSettings.AlertEnabled,
            title: '@system-insight:logs.settings.alert.items.enabled.title',
            description: '@system-insight:logs.settings.alert.items.enabled.description',
            scope: 'T',
            isInherited: true,
            defaultValue: false,
            widget: {
                type: AXPWidgetsList.Editors.ToggleSwitch,
            },
        })
            .addSetting({
            key: AXPSystemInsightSettings.AlertLogLevel,
            title: '@system-insight:logs.settings.alert.items.level.title',
            description: '@system-insight:logs.settings.alert.items.level.description',
            scope: 'T',
            isInherited: true,
            defaultValue: 'error',
            widget: {
                type: AXPWidgetsList.Editors.SelectBox,
                options: {
                    valueField: 'id',
                    textField: 'title',
                    dataSource: [
                        { id: 'error', title: '@system-insight:logs.settings.alert.items.level.options.error' },
                        { id: 'warn', title: '@system-insight:logs.settings.alert.items.level.options.warn' },
                        { id: 'info', title: '@system-insight:logs.settings.alert.items.level.options.info' },
                    ],
                    visibility: alertVisibility,
                },
            },
        })
            .addSetting({
            key: AXPSystemInsightSettings.AlertEmail,
            title: '@system-insight:logs.settings.alert.items.email.title',
            description: '@system-insight:logs.settings.alert.items.email.description',
            scope: 'T',
            isInherited: false,
            widget: {
                type: AXPWidgetsList.Editors.ContactBox,
                options: {
                    type: 'email',
                    visibility: alertVisibility,
                },
            },
            validationRules: [{ rule: 'required' }],
        })
            .endSection()
            //#endregion
            //#region ----   Performance   ----
            .addSection('performance', '@system-insight:logs.settings.performance.title', '@system-insight:logs.settings.performance.description')
            .addSetting({
            key: AXPSystemInsightSettings.AsyncLogging,
            title: '@system-insight:logs.settings.performance.items.async.title',
            description: '@system-insight:logs.settings.performance.items.async.description',
            scope: 'T',
            isInherited: true,
            defaultValue: true,
            widget: {
                type: AXPWidgetsList.Editors.ToggleSwitch,
            },
        })
            .addSetting({
            key: AXPSystemInsightSettings.BatchSize,
            title: '@system-insight:logs.settings.performance.items.batch-size.title',
            description: '@system-insight:logs.settings.performance.items.batch-size.description',
            scope: 'T',
            isInherited: true,
            defaultValue: 100,
            widget: {
                type: AXPWidgetsList.Editors.NumberBox,
                options: {
                    minValue: 1,
                    maxValue: 1000,
                    visibility: asyncVisibility,
                },
            },
        })
            .addSetting({
            key: AXPSystemInsightSettings.FlushInterval,
            title: '@system-insight:logs.settings.performance.items.flush-interval.title',
            description: '@system-insight:logs.settings.performance.items.flush-interval.description',
            scope: 'T',
            isInherited: true,
            defaultValue: 5000,
            widget: {
                type: AXPWidgetsList.Editors.NumberBox,
                options: {
                    minValue: 1000,
                    maxValue: 60000,
                    step: 1000,
                    suffix: 'ms',
                    visibility: asyncVisibility,
                },
            },
        })
            .endSection()
            //#endregion
            .endGroup();
    }
}

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

async function auditLogFactory(injector) {
    const scope = RootConfig.config.i18n;
    const entityScope = `@${scope}:logs.entities.audit-log`;
    const groupTitle = (key) => `${entityScope}.groups.${key}`;
    const fieldTitle = (key) => `${entityScope}.fields.${key}.title`;
    const viewTitle = (key) => `${entityScope}.views.${key}.title`;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.auditLog.name,
        title: RootConfig.entities.auditLog.title,
        icon: RootConfig.entities.auditLog.icon,
        formats: {
            individual: RootConfig.entities.auditLog.title,
            plural: RootConfig.entities.auditLog.titlePlural,
            searchResult: {
                title: '{{ applicationName }}',
                description: `${entityScope}.formats.search-result.description`,
            },
        },
        relatedEntities: [],
        groups: [
            { id: 'general', title: groupTitle('general') },
            { id: 'user', title: groupTitle('user') },
            { id: 'client', title: groupTitle('client') },
            { id: 'impersonator', title: groupTitle('impersonator') },
            { id: 'actions', title: groupTitle('actions') },
            { id: 'entityChanges', title: groupTitle('entity-changes') },
            { id: 'extra', title: groupTitle('extra') },
        ],
        properties: [
            // General
            {
                name: 'id',
                title: fieldTitle('id'),
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'applicationName',
                title: fieldTitle('application-name'),
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'executionTime',
                title: fieldTitle('execution-time'),
                groupId: 'general',
                schema: { dataType: 'date', interface: { type: AXPWidgetsList.Editors.DateTimeBox } },
            },
            {
                name: 'executionDuration',
                title: fieldTitle('execution-duration'),
                groupId: 'general',
                schema: { dataType: 'number', interface: { type: AXPWidgetsList.Editors.NumberBox } },
            },
            {
                name: 'comments',
                title: fieldTitle('comments'),
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            // User
            {
                name: 'tenantId',
                title: fieldTitle('tenant-id'),
                groupId: 'user',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'tenantName',
                title: fieldTitle('tenant-name'),
                groupId: 'user',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'userId',
                title: fieldTitle('user-id'),
                groupId: 'user',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'userName',
                title: fieldTitle('user-name'),
                groupId: 'user',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            // Client
            {
                name: 'clientIpAddress',
                title: fieldTitle('client-ip-address'),
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'clientName',
                title: fieldTitle('client-name'),
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'clientId',
                title: fieldTitle('client-id'),
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'browserInfo',
                title: fieldTitle('browser-info'),
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'httpMethod',
                title: fieldTitle('http-method'),
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'url',
                title: fieldTitle('url'),
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'httpStatusCode',
                title: fieldTitle('http-status-code'),
                groupId: 'client',
                schema: { dataType: 'number', interface: { type: AXPWidgetsList.Editors.NumberBox } },
            },
            {
                name: 'httpStatus',
                title: fieldTitle('http-status'),
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            // Correlation
            {
                name: 'correlationId',
                title: fieldTitle('correlation-id'),
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            // Exception
            {
                name: 'exceptions',
                title: fieldTitle('exceptions'),
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            // Impersonator
            {
                name: 'impersonatorUserId',
                title: fieldTitle('impersonator-user-id'),
                groupId: 'impersonator',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'impersonatorUserName',
                title: fieldTitle('impersonator-user-name'),
                groupId: 'impersonator',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'impersonatorTenantId',
                title: fieldTitle('impersonator-tenant-id'),
                groupId: 'impersonator',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            {
                name: 'impersonatorTenantName',
                title: fieldTitle('impersonator-tenant-name'),
                groupId: 'impersonator',
                schema: { dataType: 'string', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            // Actions
            {
                name: 'actions',
                title: fieldTitle('actions'),
                groupId: 'actions',
                schema: { dataType: 'array', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
            // EntityChanges
            {
                name: 'entityChanges',
                title: fieldTitle('entity-changes'),
                groupId: 'entityChanges',
                schema: { dataType: 'array', interface: { type: AXPWidgetsList.Editors.TextBox } },
            },
        ],
        columns: [
            { name: 'applicationName' },
            { name: 'userName' },
            { name: 'executionTime' },
            { name: 'clientIpAddress' },
            { name: 'httpMethod' },
            { name: 'url' },
            { name: 'httpStatusCode' },
            { name: 'httpStatus' },
        ],
        interfaces: {
            master: {
                create: {
                    sections: [
                        {
                            id: 'section',
                        },
                    ],
                    properties: [
                        {
                            name: 'id',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'applicationName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'executionTime',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'executionDuration',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 4,
                                    },
                                },
                            },
                        },
                        {
                            name: 'comments',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 5,
                                    },
                                },
                            },
                        },
                        {
                            name: 'tenantId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'tenantName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 7,
                                    },
                                },
                            },
                        },
                        {
                            name: 'userId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 8,
                                    },
                                },
                            },
                        },
                        {
                            name: 'userName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 9,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientIpAddress',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 10,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 11,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'browserInfo',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 13,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpMethod',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 14,
                                    },
                                },
                            },
                        },
                        {
                            name: 'url',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 15,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpStatusCode',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 16,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpStatus',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 17,
                                    },
                                },
                            },
                        },
                        {
                            name: 'correlationId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 18,
                                    },
                                },
                            },
                        },
                        {
                            name: 'exceptions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 19,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorUserId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 20,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorUserName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 21,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorTenantId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 22,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorTenantName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 23,
                                    },
                                },
                            },
                        },
                        {
                            name: 'extraProperties',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 24,
                                    },
                                },
                            },
                        },
                        {
                            name: 'actions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 25,
                                    },
                                },
                            },
                        },
                        {
                            name: 'entityChanges',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 26,
                                    },
                                },
                            },
                        },
                    ],
                },
                // update: {
                //   sections: [
                //     {
                //       id: 'section',
                //     },
                //   ],
                //   properties: [
                //     {
                //       name: 'utcTimestamp',
                //       layout: {
                //         positions: {
                //           lg: {
                //             colSpan: 2,
                //             order: 1,
                //           },
                //         },
                //       },
                //     },
                //     {
                //       name: 'message',
                //       layout: {
                //         positions: {
                //           lg: {
                //             colSpan: 3,
                //             order: 2,
                //           },
                //         },
                //       },
                //     },
                //     {
                //       name: 'level',
                //       layout: {
                //         positions: {
                //           lg: {
                //             colSpan: 2,
                //             order: 3,
                //           },
                //         },
                //       },
                //     },
                //     {
                //       name: 'properties',
                //       layout: {
                //         positions: {
                //           lg: {
                //             colSpan: 3,
                //             order: 4,
                //           },
                //         },
                //       },
                //     },
                //   ],
                // },
                single: {
                    title: viewTitle('single'),
                    sections: [
                        {
                            id: 'general',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'user',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'client',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'impersonator',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'actions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'entityChanges',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'extra',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                    ],
                    properties: [
                        {
                            name: 'id',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'applicationName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'executionTime',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'executionDuration',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'comments',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'tenantId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'tenantName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'userId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'userName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientIpAddress',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'browserInfo',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpMethod',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'url',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpStatusCode',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpStatus',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'correlationId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'exceptions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorUserId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorUserName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorTenantId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorTenantName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'extraProperties',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'actions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'entityChanges',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                    ],
                    actions: [],
                },
                list: {
                    actions: [
                        // {
                        //   title: `t("create", { scope: "common" })`,
                        //   command: 'create-entity',
                        //   priority: 'primary',
                        //   type: 'create',
                        //   scope: AXPEntityCommandScope.TypeLevel,
                        // },
                        // {
                        //   title: 't("deleteItems", { scope: "common" })',
                        //   command: 'delete-entity',
                        //   priority: 'primary',
                        //   type: 'delete',
                        //   scope: AXPEntityCommandScope.Selected,
                        // },
                        {
                            title: '@general:actions.detail.title',
                            command: 'open-entity',
                            priority: 'secondary',
                            type: 'view',
                            scope: AXPEntityCommandScope.Individual,
                        },
                        // {
                        //   title: 't("delete", { scope: "common" })',
                        //   command: 'delete-entity',
                        //   priority: 'secondary',
                        //   type: 'delete',
                        //   scope: AXPEntityCommandScope.Individual,
                        // },
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'applicationName', dir: 'asc' }],
                        }),
                        createQueryView('auth-logs', viewTitle('auth-logs'), true, {
                            conditions: [
                                {
                                    name: 'type',
                                    operator: {
                                        type: 'equal',
                                    },
                                    value: 'auth',
                                },
                            ],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

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

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

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

// Entity Services

class AXMSystemInsightModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMSystemInsightModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.19", ngImport: i0, type: AXMSystemInsightModule, imports: [
            // Entity Modules
            AXMAuditLogEntityModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMSystemInsightModule, providers: [
            // Module Manifest Provider
            {
                provide: AXP_MODULE_MANIFEST_PROVIDER,
                useValue: SystemInsightManifest,
                multi: true,
            },
            // Provider references (now using tokens)
            {
                provide: AXP_MENU_PROVIDER,
                useClass: AXMSystemInsightMenuProvider,
                multi: true,
            },
            {
                provide: AXP_ENTITY_DEFINITION_LOADER,
                useClass: AXMSystemInsightEntityProvider,
                multi: true,
            },
            {
                provide: AXP_SETTING_DEFINITION_PROVIDER,
                useClass: AXPSystemInsightSettingProvider,
                multi: true,
            },
            {
                provide: AXP_SEARCH_PROVIDER,
                useClass: AXMSystemInsightSearchCommandProvider,
                multi: true,
            },
        ], imports: [
            // Entity Modules
            AXMAuditLogEntityModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMSystemInsightModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        // Entity Modules
                        AXMAuditLogEntityModule,
                    ],
                    exports: [],
                    declarations: [],
                    providers: [
                        // Module Manifest Provider
                        {
                            provide: AXP_MODULE_MANIFEST_PROVIDER,
                            useValue: SystemInsightManifest,
                            multi: true,
                        },
                        // Provider references (now using tokens)
                        {
                            provide: AXP_MENU_PROVIDER,
                            useClass: AXMSystemInsightMenuProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_ENTITY_DEFINITION_LOADER,
                            useClass: AXMSystemInsightEntityProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SETTING_DEFINITION_PROVIDER,
                            useClass: AXPSystemInsightSettingProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SEARCH_PROVIDER,
                            useClass: AXMSystemInsightSearchCommandProvider,
                            multi: true,
                        },
                    ],
                }]
        }] });

//export * from './lib/pages';

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

export { AXMSystemInsightAuditLogService, AXMSystemInsightAuditLogServiceImpl, AXMSystemInsightEntityProvider, AXMSystemInsightMenuProvider, AXMSystemInsightModule, AXMSystemInsightSearchCommandProvider, AXPSystemInsightSettingProvider, RootConfig, auditLogFactory };
//# sourceMappingURL=acorex-modules-system-insight.mjs.map
