import { AXPWidgetsList } from '@acorex/modules/common';
import { createAllQueryView } from '@acorex/platform/common';
import { entityMasterCrudActions, entityMasterRecordActions } from '@acorex/platform/layout/entity';
import { R as RootConfig } from './acorex-modules-assessment-management-acorex-modules-assessment-management-W8hHssaa.mjs';

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function factory(injector) {
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.questionBankItem.name,
        title: RootConfig.entities.questionBankItem.title,
        icon: RootConfig.entities.questionBankItem.icon,
        plugins: [
            { name: 'category' },
            { name: 'tags' },
            { name: 'history' },
            { name: 'lock' },
            { name: 'compare' },
            { name: 'archive' },
            { name: 'audit-info' },
            { name: 'clone' },
        ],
        formats: {
            individual: RootConfig.entities.questionBankItem.title,
            plural: RootConfig.entities.questionBankItem.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: RootConfig.module.title,
            },
        },
        groups: [
            { id: 'basic-info', title: '@general:terms.interface.basic-info' },
            { id: 'scoring', title: '@assessment-management:question-bank.entities.question-bank-item.groups.scoring' },
            {
                id: 'question-properties',
                title: '@assessment-management:question-bank.entities.question-bank-item.groups.question-properties',
            },
            { id: 'user-interface', title: '@general:terms.interface.user-interface' },
        ],
        properties: [
            {
                name: 'id',
                title: 'ID',
                groupId: 'basic-info',
                schema: { dataType: 'uuid', visible: false, nullable: false, readonly: true, unique: { enabled: true } },
            },
            {
                name: 'title',
                title: '@assessment-management:question-bank.entities.question-bank-item.fields.title.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: { type: AXPWidgetsList.Editors.TextBox, options: { placeholder: 'Enter question text...' } },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@assessment-management:question-bank.entities.question-bank-item.fields.description.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: false },
                    filter: { advance: { enabled: true }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: { rows: 3, placeholder: 'Help text or additional context...' },
                    },
                },
            },
            {
                name: 'interface',
                title: `@assessment-management:question-bank.entities.question-bank-item.fields.interface.title`,
                groupId: 'user-interface',
                options: {
                    sort: { enabled: false },
                    filter: { advance: { enabled: false }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'object',
                    interface: {
                        type: 'widget-field-configurator',
                        options: {
                            fieldName: "{{ context.eval('title') }}",
                            label: '@general:terms.common.widget',
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'scoringType',
                title: '@assessment-management:question-bank.entities.question-bank-item.fields.scoring-type.title',
                groupId: 'scoring',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    defaultValue: 'none',
                    interface: {
                        type: AXPWidgetsList.Editors.SelectBox,
                        options: {
                            valueField: 'id',
                            dataSource: [
                                {
                                    id: 'none',
                                    title: '@assessment-management:question-bank.entities.question-bank-item.fields.scoring-type.options.none',
                                },
                                {
                                    id: 'points',
                                    title: '@assessment-management:question-bank.entities.question-bank-item.fields.scoring-type.options.points',
                                },
                                {
                                    id: 'weighted',
                                    title: '@assessment-management:question-bank.entities.question-bank-item.fields.scoring-type.options.weighted',
                                },
                                {
                                    id: 'formula',
                                    title: '@assessment-management:question-bank.entities.question-bank-item.fields.scoring-type.options.formula',
                                },
                            ],
                        },
                    },
                },
            },
            {
                name: 'points',
                title: '@assessment-management:question-bank.entities.question-bank-item.fields.points.title',
                groupId: 'scoring',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            minValue: 0,
                            placeholder: 'Points for correct answer',
                            visibility: `{{ context.eval('scoringType') === 'points' || context.eval('scoringType') === 'weighted' }}`,
                        },
                    },
                },
            },
            {
                name: 'weight',
                title: '@assessment-management:question-bank.entities.question-bank-item.fields.weight.title',
                groupId: 'scoring',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            minValue: 0,
                            maxValue: 1,
                            placeholder: '0.0 - 1.0',
                            visibility: `{{ context.eval('scoringType') === 'weighted' }}`,
                        },
                    },
                },
            },
            {
                name: 'correctAnswer',
                title: '@assessment-management:question-bank.entities.question-bank-item.fields.correct-answer.title',
                groupId: 'scoring',
                options: {
                    sort: { enabled: false },
                    filter: { advance: { enabled: false }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 2,
                            placeholder: 'Correct answer for auto-scoring (JSON format)',
                            visibility: `{{ context.eval('scoringType') !== 'none' }}`,
                        },
                    },
                },
            },
            {
                name: 'difficulty',
                title: '@assessment-management:question-bank.entities.question-bank-item.fields.difficulty.title',
                groupId: 'question-properties',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.SelectBox,
                        options: {
                            valueField: 'id',
                            dataSource: [
                                {
                                    id: 'easy',
                                    title: '@assessment-management:question-bank.entities.question-bank-item.fields.difficulty.options.easy',
                                },
                                {
                                    id: 'medium',
                                    title: '@assessment-management:question-bank.entities.question-bank-item.fields.difficulty.options.medium',
                                },
                                {
                                    id: 'hard',
                                    title: '@assessment-management:question-bank.entities.question-bank-item.fields.difficulty.options.hard',
                                },
                            ],
                        },
                    },
                },
            },
            {
                name: 'estimatedTime',
                title: '@assessment-management:question-bank.entities.question-bank-item.fields.estimated-time.title',
                groupId: 'question-properties',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            minValue: 0,
                            placeholder: 'Estimated time in seconds',
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'title' },
            { name: 'difficulty' },
            { name: 'scoringType' },
            { name: 'points' },
            { name: 'estimatedTime' },
            { name: 'interface' },
        ],
        interfaces: {
            master: {
                create: {
                    sections: [
                        { id: 'basic-info', order: 1, layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'scoring', order: 2, layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'question-properties', order: 3, layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'user-interface', order: 4, layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'scoringType', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'points', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'weight', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'correctAnswer', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'difficulty', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'estimatedTime', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'interface', layout: { label: { visible: false }, positions: { lg: { colSpan: 12 } } } },
                    ],
                },
                update: {
                    sections: [
                        { id: 'basic-info', order: 1, layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'scoring', order: 2, layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'question-properties', order: 3, layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'user-interface', order: 4, layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'scoringType', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'points', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'weight', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'correctAnswer', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'difficulty', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'estimatedTime', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'interface', layout: { label: { visible: false }, positions: { lg: { colSpan: 12 } } } },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [
                        { id: 'basic-info', order: 1, layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'scoring', order: 2, layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'question-properties', order: 3, layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'user-interface', order: 4, layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'scoringType', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'points', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'weight', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'correctAnswer', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'difficulty', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'estimatedTime', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'interface', layout: { label: { visible: false }, positions: { lg: { colSpan: 12 } } } },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [createAllQueryView({ sorts: [{ name: 'title', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

export { factory };
//# sourceMappingURL=acorex-modules-assessment-management-question-bank-item.entity-bELSO0yJ.mjs.map
