import { render } from 'lit';
import { Renderer, renderFn } from './Renderer.js';
export class FragmentRenderer extends Renderer {
    fragment;
    constructor(fragment) {
        super();
        this.fragment = fragment;
    }
    [renderFn]() {
        const root = this.renderRoot;
        if (!root) {
            // return quietly. Fragments can be rendered directly.
            return;
        }
        const fragment = this.fragment;
        const host = fragment.getSingleVisibleFragment() || fragment;
        if (!this.firstRendered) {
            this.firstRenderedFlag = true;
            // cleanup any pre-existing content.
            Array.from(root.childNodes).forEach((node) => root.parentNode?.removeChild(node));
            setTimeout(() => host.onFirstRender());
        }
        const litPart = root;
        if (litPart._$litPart$) {
            ;
            litPart._$litPart$.options.host = host;
        }
        // console.log(host, root)
        render(host.render(), root, { host });
        this.resolveUpdatePromise();
        // this.app.onRendered()
    }
}
//# sourceMappingURL=FragmentRenderer.js.map