import { ComponentFactoryResolver, NgModule } from '@angular/core';
import { CommonModule as NGCommonModule, APP_BASE_HREF } from '@angular/common';

{{WMComponentsImportStmts requiredWMComponents}}
import { ComponentType,  RuntimeBaseModule } from '@wm/runtime/base';

{{#if insidePrefab}}
    import { ComponentRefProviderService } from '../../../../../framework/services/component-ref-provider.service';
{{else}}
    import { ComponentRefProviderService } from '../../../framework/services/component-ref-provider.service';
{{/if}}

{{PartialModuleImportStmts requiredPartials}}

import { {{componentName}} } from './{{name}}.component';

const components = [{{componentName}}];

const requiredComponentModules = [
    {{WMComponentModuleStmts requiredWMComponents}}
];

const requiredPartialModules: any[] = [
    {{PartialModuleStmts requiredPartials}}
];

@NgModule({
    declarations: components,
    imports: [
        ...requiredComponentModules,
        ...requiredPartialModules,
        NGCommonModule,
        RuntimeBaseModule
    ],
    exports: components,
})
export class {{moduleName}} {
    static rootComponent = {{componentName}};
    constructor(componentFactoryResolver: ComponentFactoryResolver) {
        const cf = componentFactoryResolver.resolveComponentFactory({{componentName}});
        ComponentRefProviderService.registerComponentRef('{{name}}', ComponentType.PARTIAL, {{componentName}}, cf);
    }
}
