import chalk from 'chalk';
import * as _ from 'lodash-es';
import needleClientBase from '../../client/needle-api/needle-client.mjs';
import { stripMargin } from '../../base/support/index.mjs';
export default class extends needleClientBase {
    addAppSCSSStyle(style, comment) {
        const filePath = `${this.clientSrcDir}app/app.scss`;
        this.addStyle(style, comment, filePath, 'jhipster-needle-scss-add-main');
    }
    addEntityToMenu(routerName, enableTranslation, entityTranslationKeyMenu, entityTranslationValue = _.startCase(routerName)) {
        const errorMessage = `${chalk.yellow('Reference to ') + routerName} ${chalk.yellow('not added to menu.\n')}`;
        const entityMenuPath = `${this.clientSrcDir}app/entities/menu.tsx`;
        const entityEntry = stripMargin(`|<MenuItem icon="asterisk" to="/${routerName}">
                        |        ${enableTranslation ? `<Translate contentKey="global.menu.entities.${entityTranslationKeyMenu}" />` : `${entityTranslationValue}`}
                        |      </MenuItem>`);
        const rewriteFileModel = this.generateFileModel(entityMenuPath, 'jhipster-needle-add-entity-to-menu', entityEntry);
        this.addBlockContentToFile(rewriteFileModel, errorMessage);
    }
    addEntityToModule(entityInstance, entityClass, entityName, entityFolderName, entityFileName, { applicationTypeMicroservice, clientSrcDir }) {
        const indexModulePath = `${clientSrcDir}app/entities/routes.tsx`;
        const indexReducerPath = `${clientSrcDir}app/entities/reducers.ts`;
        const errorMessage = path => `${chalk.yellow('Reference to ') + entityInstance + entityClass + entityFolderName + entityFileName} ${chalk.yellow(`not added to ${path}.\n`)}`;
        const indexAddRouteImportRewriteFileModel = this.generateFileModel(indexModulePath, 'jhipster-needle-add-route-import', stripMargin(`|import ${entityName} from './${entityFolderName}';`));
        this.addBlockContentToFile(indexAddRouteImportRewriteFileModel, errorMessage(indexModulePath));
        const indexAddRoutePathRewriteFileModel = this.generateFileModel(indexModulePath, 'jhipster-needle-add-route-path', stripMargin(`|<Route path="${applicationTypeMicroservice ? '/' : ''}${entityFileName}/*" element={<${entityName} />} />`));
        this.addBlockContentToFile(indexAddRoutePathRewriteFileModel, errorMessage(indexModulePath));
        const reducerAddImportRewriteFileModel = this.generateFileModel(indexReducerPath, 'jhipster-needle-add-reducer-import', stripMargin(`import ${entityInstance} from 'app/entities/${entityFolderName}/${entityFileName}.reducer';`));
        this.addBlockContentToFile(reducerAddImportRewriteFileModel, errorMessage(indexReducerPath));
        const reducerAddCombineRewriteFileModel = this.generateFileModel(indexReducerPath, 'jhipster-needle-add-reducer-combine', stripMargin(`|  ${entityInstance},`));
        this.addBlockContentToFile(reducerAddCombineRewriteFileModel, errorMessage(indexReducerPath));
    }
}
