import * as i0 from '@angular/core';
import { inject, DestroyRef, Component, ContentChild, Input } from '@angular/core';
import { NgTemplateOutlet, NgIf } from '@angular/common';
import { Title, Meta } from '@angular/platform-browser';
import { LdcLoadingComponent } from '@testlocallibrary/shared-kernel/components/ldc-loading';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { TranslationService, LanguageService } from '@testlocallibrary/shared-kernel/services/language';

class LdcContainerComponent {
    constructor() {
        this._translate = inject(TranslationService);
        this._language = inject(LanguageService);
        this._title = inject(Title);
        this._meta = inject(Meta);
        this.language = this._language.getLanguage() || "en";
        this.destroyRef = inject(DestroyRef);
    }
    ngOnInit() {
        this._translate.setLanguage(this.language);
        this._translate.translateGet(this.contentName).pipe(takeUntilDestroyed(this.destroyRef))
            .subscribe((content) => {
            this.contentTranslated = content;
            this.setMetaTags(content);
        });
    }
    setMetaTags(content) {
        //* as keyof string is a workaround for the type system
        const metaTags = content['metaTags'];
        for (const contentElementElement in metaTags) {
            const value = metaTags[contentElementElement];
            if (contentElementElement === 'title') {
                this._title.setTitle(value);
            }
            else {
                this._meta.updateTag({
                    name: contentElementElement,
                    content: value
                });
            }
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LdcContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: LdcContainerComponent, isStandalone: true, selector: "lib-ldc-container", inputs: { contentName: "contentName" }, queries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: "<ng-container *ngIf=\"(contentName && contentTranslated )else loader\">\r\n  <ng-container\r\n    *ngTemplateOutlet=\"\r\n            container;\r\n            context: {\r\n              contentTranslated: contentTranslated,\r\n            }\r\n          \"\r\n  ></ng-container>\r\n</ng-container>\r\n\r\n\r\n<!--\r\n  Loader is a component that shows a spinner when isLoading is true\r\n  you can use it in your project or you can use a spinner from a library like angular material\r\n-->\r\n<ng-template #loader>\r\n  <lib-ldc-loading class=\"loader\"  [isLoading]=\"true\"></lib-ldc-loading>\r\n</ng-template>\r\n", styles: [""], dependencies: [{ kind: "component", type: LdcLoadingComponent, selector: "lib-ldc-loading", inputs: ["isLoading", "alignLoading"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LdcContainerComponent, decorators: [{
            type: Component,
            args: [{ selector: 'lib-ldc-container', standalone: true, imports: [LdcLoadingComponent, NgTemplateOutlet, NgIf], template: "<ng-container *ngIf=\"(contentName && contentTranslated )else loader\">\r\n  <ng-container\r\n    *ngTemplateOutlet=\"\r\n            container;\r\n            context: {\r\n              contentTranslated: contentTranslated,\r\n            }\r\n          \"\r\n  ></ng-container>\r\n</ng-container>\r\n\r\n\r\n<!--\r\n  Loader is a component that shows a spinner when isLoading is true\r\n  you can use it in your project or you can use a spinner from a library like angular material\r\n-->\r\n<ng-template #loader>\r\n  <lib-ldc-loading class=\"loader\"  [isLoading]=\"true\"></lib-ldc-loading>\r\n</ng-template>\r\n" }]
        }], propDecorators: { container: [{
                type: ContentChild,
                args: ["container"]
            }], contentName: [{
                type: Input,
                args: [{ required: true, alias: 'contentName' }]
            }] } });

/**
 * Generated bundle index. Do not edit.
 */

export { LdcContainerComponent };
//# sourceMappingURL=testlocallibrary-shared-kernel-components-ldc-container.mjs.map
