import { createAllQueryView } from '@acorex/platform/common';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { entityMasterCrudActions, entityMasterRecordActions } from '@acorex/platform/layout/entity';
import { RootConfig as RootConfig$1 } from './acorex-modules-product-catalog.mjs';
import { RootConfig } from '@acorex/modules/business-core';

//#region ----   Imports   ----
//#endregion
async function brandFactory(injector) {
    const entityDef = {
        module: RootConfig$1.module.name,
        name: RootConfig$1.entities.brand.name,
        title: RootConfig$1.entities.brand.title,
        icon: RootConfig$1.entities.brand.icon,
        formats: {
            individual: RootConfig$1.entities.brand.title,
            plural: RootConfig$1.entities.brand.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: RootConfig$1.module.title,
            },
        },
        plugins: [
            { name: 'history' },
            { name: 'lock' },
            { name: 'compare' },
            { name: 'clone' },
            { name: 'category', options: { appearance: { icon: true, color: true }, metaData: { enabled: true } } },
            { name: 'meta-data-form', options: { path: 'categoryIds' } },
            { name: 'archive' },
        ],
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
            {
                id: 'manufacturer',
                title: '@product-catalog:brands.entities.brand.groups.manufacturer-info',
            },
        ],
        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., BRAND-001',
                        },
                    },
                },
                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,
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.largeText,
                        options: {
                            rows: 3,
                        },
                    },
                },
            },
            {
                name: 'logo',
                title: '@product-catalog:brands.entities.brand.fields.logo.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: false },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.avatar,
                        options: {
                            accept: ['.jpg', '.jpeg', '.png', '.svg'],
                            maxSize: 2048,
                        },
                    },
                },
            },
            {
                name: 'manufacturerId',
                title: '@product-catalog:brands.entities.brand.fields.manufacturer.title',
                groupId: 'manufacturer',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.lookup,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.manufacturer.name}`,
                            multiple: false,
                            expose: [
                                { source: 'id', target: 'manufacturer.id' },
                                { source: 'title', target: 'manufacturer.title' },
                            ],
                        },
                    },
                },
            },
            {
                name: 'countryOfOrigin',
                title: '@product-catalog:brands.entities.brand.fields.country-of-origin.title',
                groupId: 'manufacturer',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                    },
                },
            },
            {
                name: 'website',
                title: '@product-catalog:brands.entities.brand.fields.website.title',
                groupId: 'manufacturer',
                options: {
                    sort: { enabled: false },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: false },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                        options: {
                            placeholder: 'https://www.example.com',
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'code' },
            { name: 'title' },
            { name: 'countryOfOrigin' },
        ],
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }, { id: 'manufacturer' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'logo', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                        { name: 'manufacturerId', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'countryOfOrigin', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                        { name: 'website', layout: { positions: { lg: { colSpan: 12, order: 7 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }, { id: 'manufacturer' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'logo', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                        { name: 'manufacturerId', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'countryOfOrigin', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                        { name: 'website', layout: { positions: { lg: { colSpan: 12, order: 7 } } } },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [{ id: 'basic-info' }, { id: 'manufacturer' }],
                    properties: [
                        { name: 'code', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'logo', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                        { name: 'manufacturerId', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
                        { name: 'countryOfOrigin', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                        { name: 'website', layout: { positions: { lg: { colSpan: 12, order: 7 } } } },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'title', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

export { brandFactory };
//# sourceMappingURL=acorex-modules-product-catalog-brand.entity-C8VOfwF0.mjs.map
