import { Directive, Inject, TemplateRef, ViewContainerRef } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import * as i0 from "@angular/core";
//TODO: remove and use one from common
/**
 * Renders element into body directly at the end
 */
export class BodyRenderSADirective {
    //######################### constructor #########################
    constructor(template, viewContainer, document) {
        this.template = template;
        this.viewContainer = viewContainer;
        this.document = document;
    }
    //######################### public methods - implementation of OnInit #########################
    /**
     * Initialize component
     */
    ngOnInit() {
        this.view = this.viewContainer
            .createEmbeddedView(this.template);
        this.element = this.view.rootNodes[0];
        this.document.body.appendChild(this.element);
    }
    //######################### public methods - implementation of OnDestroy #########################
    /**
     * Called when component is destroyed
     */
    ngOnDestroy() {
        this.element?.remove();
        this.element = null;
        this.view?.destroy();
        this.view = null;
    }
}
BodyRenderSADirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: BodyRenderSADirective, deps: [{ token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Directive });
BodyRenderSADirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.4", type: BodyRenderSADirective, isStandalone: true, selector: "[bodyRender]", ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: BodyRenderSADirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[bodyRender]',
                    standalone: true
                }]
        }], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: Document, decorators: [{
                    type: Inject,
                    args: [DOCUMENT]
                }] }] });
//# sourceMappingURL=bodyRender.directive.js.map