import { asWritingEntitiesTask, asWritingTask } from '../base-application/support/index.js';
import { clientApplicationTemplatesBlock, clientRootTemplatesBlock, clientSrcTemplatesBlock } from '../client/support/files.js';
export const vueFiles = {
    common: [
        clientRootTemplatesBlock({
            templates: [
                { sourceFile: 'eslint.config.js.jhi.vue', destinationFile: ctx => `${ctx.eslintConfigFile}.jhi.vue` },
                'vite.config.mts',
            ],
        }),
    ],
    microfrontend: [
        clientRootTemplatesBlock({
            condition: generator => generator.microfrontend && false,
            templates: ['module-federation.config.cjs'],
        }),
        clientRootTemplatesBlock({
            condition: ctx => ctx.microfrontend && ctx.clientBundlerWebpack,
            templates: [
                'webpack/config.js',
                'webpack/webpack.common.js',
                'webpack/webpack.dev.js',
                'webpack/webpack.prod.js',
                'webpack/vue.utils.js',
            ],
        }),
        {
            condition: generator => generator.microfrontend,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: ['index.ts', 'core/error/error-loading.vue'],
        },
        {
            condition: generator => generator.applicationTypeMicroservice,
            ...clientApplicationTemplatesBlock(),
            templates: ['entities/entities-menu.spec.ts'],
        },
    ],
    sass: [
        {
            ...clientSrcTemplatesBlock(),
            path: 'src/main/webapp/',
            templates: ['content/scss/_bootstrap-variables.scss', 'content/scss/global.scss', 'content/scss/vendor.scss'],
        },
    ],
    vueApp: [
        {
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: [
                'app.vue',
                'app.component.ts',
                'shims-vue.d.ts',
                'constants.ts',
                'declarations.d.ts',
                'main.ts',
                'shared/alert/alert.service.ts',
                'shared/alert/alert.service.spec.ts',
                'shared/config/axios-interceptor.ts',
                'shared/config/axios-interceptor.spec.ts',
                'shared/config/config.ts',
                'shared/config/config-bootstrap-vue.ts',
                'shared/config/dayjs.ts',
                'shared/config/store/account-store.ts',
                'shared/security/authority.ts',
                'store.ts',
                'router/index.ts',
                'router/admin.ts',
                'router/pages.ts',
                'test-setup.ts',
            ],
        },
    ],
    i18n: [
        {
            condition: generator => generator.enableTranslation,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: ['locale/translation.service.ts', 'shared/config/store/translation-store.ts', 'shared/config/languages.ts'],
        },
    ],
    sharedVueApp: [
        {
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: [
                'core/home/home.vue',
                'core/home/home.component.ts',
                'core/home/home.component.spec.ts',
                'core/error/error.vue',
                'core/error/error.component.ts',
                'core/error/error.component.spec.ts',
                'core/jhi-footer/jhi-footer.vue',
                'core/jhi-footer/jhi-footer.component.ts',
                'core/jhi-navbar/jhi-navbar.vue',
                'core/jhi-navbar/jhi-navbar.component.ts',
                'core/jhi-navbar/jhi-navbar.component.spec.ts',
                'core/ribbon/ribbon.vue',
                'core/ribbon/ribbon.component.ts',
                'core/ribbon/ribbon.component.spec.ts',
                'shared/composables/date-format.ts',
                'shared/composables/index.ts',
                'shared/composables/validation.ts',
                'shared/computables/arrays.ts',
                'shared/computables/index.ts',
                'shared/sort/jhi-sort-indicator.component.ts',
                'shared/sort/jhi-sort-indicator.vue',
                'shared/sort/sorts.ts',
                'shared/sort/sorts.spec.ts',
                'shared/data/data-utils.service.ts',
                'shared/data/data-utils.service.spec.ts',
                'shared/jhi-item-count.component.ts',
                'shared/jhi-item-count.vue',
                'shared/model/user.model.ts',
            ],
        },
    ],
    accountModule: [
        {
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: ['account/account.service.ts', 'account/account.service.spec.ts'],
        },
        {
            condition: generator => !generator.authenticationTypeOauth2,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: [
                'account/login-form/login-form.vue',
                'account/login-form/login-form.component.ts',
                'account/login-form/login-form.component.spec.ts',
                'account/login.service.ts',
                'router/account.ts',
            ],
        },
        {
            condition: generator => generator.generateUserManagement,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: [
                'account/change-password/change-password.vue',
                'account/change-password/change-password.component.ts',
                'account/change-password/change-password.component.spec.ts',
                'account/register/register.vue',
                'account/register/register.component.ts',
                'account/register/register.component.spec.ts',
                'account/register/register.service.ts',
                'account/reset-password/init/reset-password-init.vue',
                'account/reset-password/init/reset-password-init.component.ts',
                'account/reset-password/init/reset-password-init.component.spec.ts',
                'account/reset-password/finish/reset-password-finish.vue',
                'account/reset-password/finish/reset-password-finish.component.ts',
                'account/reset-password/finish/reset-password-finish.component.spec.ts',
                'account/settings/settings.vue',
                'account/settings/settings.component.ts',
                'account/settings/settings.component.spec.ts',
                'account/activate/activate.component.ts',
                'account/activate/activate.component.spec.ts',
                'account/activate/activate.service.ts',
                'account/activate/activate.vue',
            ],
        },
        {
            condition: generator => generator.authenticationTypeSession && generator.generateUserManagement,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: [
                'account/sessions/sessions.vue',
                'account/sessions/sessions.component.ts',
                'account/sessions/sessions.component.spec.ts',
                'account/login.service.spec.ts',
            ],
        },
        {
            condition: generator => generator.authenticationTypeOauth2,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: ['account/login.service.ts', 'account/login.service.spec.ts'],
        },
    ],
    adminModule: [
        {
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: ['admin/docs/docs.vue', 'admin/docs/docs.component.ts'],
        },
        {
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            condition: generator => generator.withAdminUi && false,
            templates: [
                'admin/configuration/configuration.vue',
                'admin/configuration/configuration.component.ts',
                'admin/configuration/configuration.component.spec.ts',
                'admin/configuration/configuration.service.ts',
                'admin/health/health.vue',
                'admin/health/health.component.ts',
                'admin/health/health.component.spec.ts',
                'admin/health/health-modal.vue',
                'admin/health/health-modal.component.ts',
                'admin/health/health-modal.component.spec.ts',
                'admin/health/health.service.ts',
                'admin/health/health.service.spec.ts',
                'admin/logs/logs.vue',
                'admin/logs/logs.component.ts',
                'admin/logs/logs.component.spec.ts',
                'admin/logs/logs.service.ts',
                'admin/metrics/metrics.vue',
                'admin/metrics/metrics.component.ts',
                'admin/metrics/metrics.component.spec.ts',
                'admin/metrics/metrics.service.ts',
                'admin/metrics/metrics-modal.vue',
                'admin/metrics/metrics-modal.component.ts',
                'admin/metrics/metrics-modal.component.spec.ts',
            ],
        },
        {
            condition: generator => generator.communicationSpringWebsocket,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: [
                'admin/tracker/tracker.vue',
                'admin/tracker/tracker.component.ts',
                'admin/tracker/tracker.component.spec.ts',
                'admin/tracker/tracker.service.ts',
                'admin/tracker/tracker.service.spec.ts',
            ],
        },
        {
            condition: generator => generator.generateUserManagement && false,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: [
                'admin/user-management/user-management.vue',
                'admin/user-management/user-management.component.ts',
                'admin/user-management/user-management.component.spec.ts',
                'admin/user-management/user-management-view.vue',
                'admin/user-management/user-management-view.component.ts',
                'admin/user-management/user-management-view.component.spec.ts',
                'admin/user-management/user-management-edit.vue',
                'admin/user-management/user-management-edit.component.ts',
                'admin/user-management/user-management-edit.component.spec.ts',
                'admin/user-management/user-management.service.ts',
            ],
        },
        {
            condition: ctx => ctx.applicationTypeGateway && ctx.gatewayServicesApiAvailable,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: [
                'admin/gateway/gateway.vue',
                'admin/gateway/gateway.component.ts',
                'admin/gateway/gateway.component.spec.ts',
                'admin/gateway/gateway.service.ts',
            ],
        },
        {
            condition: generator => generator.generateBuiltInUserEntity && false,
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: ['entities/user/user.service.ts'],
        },
    ],
};
export const entitiesFiles = {
    entities: [
        {
            ...clientApplicationTemplatesBlock(),
            path: 'src/main/webapp/app/',
            templates: [
                'entities/entities.component.ts',
                'entities/entities.vue',
                'entities/entities-menu.component.ts',
                'entities/entities-menu.vue',
                'router/entities.ts',
            ],
        },
    ],
};
export const writeFiles = asWritingTask(async function writeFiles({ application }) {
    await this.writeFiles({
        sections: vueFiles,
        context: application,
    });
});
export const writeEntitiesFiles = asWritingEntitiesTask(async function writeEntitiesFiles({ application, entities }) {
    entities = entities.filter(entity => !entity.skipClient && !entity.builtInUser);
    await this.writeFiles({
        sections: entitiesFiles,
        context: {
            ...application,
            entities,
        },
    });
});
