import { loadClientConfig, loadDerivedClientConfig, preparePostEntityClientDerivedProperties } from '../client/support/index.mjs';
import BaseApplicationGenerator from '../base-application/index.mjs';
import { GENERATOR_BOOTSTRAP_APPLICATION_BASE, GENERATOR_BOOTSTRAP_APPLICATION_CLIENT } from '../generator-list.mjs';
import { loadStoredAppOptions } from '../app/support/index.mjs';
import clientCommand from '../client/command.mjs';
import { loadConfig, loadDerivedConfig } from '../../lib/internal/index.mjs';
export default class BootStrapApplicationClient extends BaseApplicationGenerator {
    constructor(args, options, features) {
        super(args, options, { jhipsterBootstrap: false, ...features });
        if (this.options.help)
            return;
        loadStoredAppOptions.call(this);
    }
    async beforeQueue() {
        if (!this.fromBlueprint) {
            await this.composeWithBlueprints(GENERATOR_BOOTSTRAP_APPLICATION_CLIENT);
        }
        if (this.delegateToBlueprint) {
            throw new Error('Only sbs blueprint is supported');
        }
        await this.dependsOnJHipster(GENERATOR_BOOTSTRAP_APPLICATION_BASE);
    }
    get loading() {
        return this.asLoadingTaskGroup({
            loadApplication({ application }) {
                loadConfig(clientCommand.configs, { config: this.jhipsterConfigWithDefaults, application });
                loadClientConfig({ config: this.jhipsterConfigWithDefaults, application });
            },
        });
    }
    get [BaseApplicationGenerator.LOADING]() {
        return this.loading;
    }
    get preparing() {
        return this.asPreparingTaskGroup({
            prepareApplication({ application }) {
                loadDerivedConfig(clientCommand.configs, { application });
                loadDerivedClientConfig({ application });
            },
        });
    }
    get [BaseApplicationGenerator.PREPARING]() {
        return this.preparing;
    }
    get postPreparingEachEntity() {
        return this.asPostPreparingEachEntityTaskGroup({
            postPreparingEntity({ entity }) {
                preparePostEntityClientDerivedProperties(entity);
            },
        });
    }
    get [BaseApplicationGenerator.POST_PREPARING_EACH_ENTITY]() {
        return this.postPreparingEachEntity;
    }
}
