/*
 * ******************************************************************
 * Copyright (c) 2024 Broadcom. All Rights Reserved.
 * Broadcom Confidential. The term "Broadcom" refers to Broadcom Inc.
 * and/or its subsidiaries.
 * ******************************************************************
 */

import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { I18nModule } from "@vcd/i18n";
import { ExtensionRouterLinkPipe } from "../../app/navigation/extension-router-link.pipe";
import { ExtensionManifestLocalization } from "../display/extension-manifest-localizaton.pipe";
import {
    ExtensionApplicationCustomElementsContainerComponent
} from "./extension-application-custom-elements-container.component";
import { ExtensionApplicationsComponent } from "./extension-application.component";
import { ExtensionComponentRegistry } from "./extension-component.registry";
import { ExtensionContainerComponent } from "./extension-container/extension-container.component";

/**
 * This is singleton to avoid re-instantiatiation across module boundaries.
 * We explicitly only ever want _one_, global, registry.
 */
const singletonExtensionComponentRegistry = new ExtensionComponentRegistry();

export function extensionComponentRegistryFactory(): ExtensionComponentRegistry {
    return singletonExtensionComponentRegistry;
}

const exportedDeclarations = [
    ExtensionContainerComponent,
    ExtensionManifestLocalization,
    ExtensionRouterLinkPipe,
    ExtensionApplicationsComponent,
    ExtensionApplicationCustomElementsContainerComponent,
];

@NgModule({
    imports: [
        I18nModule,
        CommonModule
    ],
    declarations: [...exportedDeclarations],
    exports: [...exportedDeclarations],
})
export class ExtensibilityModule {
}
