import { createAllQueryView, AXPEntityQueryType } from '@acorex/platform/common';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { c as AXMCustomerManagementLeadEntityService, R as RootConfig } from './acorex-modules-customer-management-acorex-modules-customer-management-DJHmt24j.mjs';
import { entityMasterCrudActions } from '@acorex/platform/layout/entity';

async function leadFactory(injector) {
    const dataService = injector.get(AXMCustomerManagementLeadEntityService);
    const i18n = RootConfig.config.i18n;
    const entityName = 'lead';
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.lead.name,
        title: RootConfig.entities.lead.title,
        icon: RootConfig.entities.lead.icon,
        formats: {
            individual: `t("${entityName}.individual-title", { scope: "${i18n}" })`,
            plural: `t("${entityName}.plural-title", { scope: "${i18n}" })`,
            searchResult: { title: '{{ name }}', description: RootConfig.module.title },
        },
        groups: [
            { id: 'basic-info', title: `t("${entityName}.basic-info", { scope: "${i18n}" })` },
            { id: 'additional', title: '@general:terms.interface.additional-info' },
        ],
        properties: [
            { name: 'name', title: `t("${entityName}.name", { scope: "${i18n}" })`, groupId: 'basic-info', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } }, validations: [{ rule: 'required' }] },
            { name: 'status', title: `t("${entityName}.status", { scope: "${i18n}" })`, groupId: 'basic-info', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.select, options: { valueField: 'id', dataSource: [{ id: 'new', title: 'New' }, { id: 'working', title: 'Working' }, { id: 'qualified', title: 'Qualified' }, { id: 'unqualified', title: 'Unqualified' }] } } } },
            { name: 'source', title: `t("${entityName}.source", { scope: "${i18n}" })`, groupId: 'basic-info', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } } },
            { name: 'email', title: `t("${entityName}.email", { scope: "${i18n}" })`, groupId: 'additional', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.contact, options: { type: 'email' } } } },
            { name: 'phone', title: `t("${entityName}.phone", { scope: "${i18n}" })`, groupId: 'additional', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.contact, options: { type: 'phone' } } } },
            { name: 'company', title: `t("${entityName}.company", { scope: "${i18n}" })`, groupId: 'additional', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } } },
        ],
        columns: [{ name: 'name' }, { name: 'email' }, { name: 'phone' }, { name: 'company' }, { name: 'status' }],
        commands: {
            create: { execute: async (data) => ({ id: await dataService.insertOne(data) }) },
            delete: { execute: async (id) => await dataService.deleteOne(id) },
            update: { execute: async (data) => await dataService.updateOne(data.id, data) },
        },
        queries: {
            byKey: { execute: async (id) => await dataService.getOne(id), type: AXPEntityQueryType.Single },
            list: { execute: async (e) => await dataService.query(e), type: AXPEntityQueryType.List },
        },
        interfaces: {
            master: {
                create: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'additional' },
                    ],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'status', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'source', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'email', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'phone', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'company', layout: { positions: { lg: { colSpan: 12, order: 6 } } } },
                    ],
                },
                update: {
                    sections: [
                        { id: 'basic-info' },
                        { id: 'additional' },
                    ],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'status', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'source', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'email', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'phone', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'company', layout: { positions: { lg: { colSpan: 12, order: 6 } } } },
                    ],
                },
                single: {
                    title: '{{name}}',
                    sections: [
                        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'additional', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'status', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'source', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
                        { name: 'email', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'phone', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'company', layout: { positions: { lg: { colSpan: 12, order: 6 } } } },
                    ],
                    actions: [],
                },
                list: { actions: [...entityMasterCrudActions()], views: [createAllQueryView({ sorts: [{ name: 'name', dir: 'asc' }] })] },
            },
        },
    };
    return entityDef;
}

export { leadFactory };
//# sourceMappingURL=acorex-modules-customer-management-lead.entity-jf7hHR9f.mjs.map
