import { render } from 'preact';
import { cancelElementTemplateRemovedSubtreeCleanup, resetElementTemplateCommitState } from './commit-hook.js';
import { resetElementTemplateHydrationListener } from './hydration-listener.js';
import { backgroundElementTemplateInstanceManager } from './manager.js';
import { clearEventState } from '../prop-adapters/event.js';
import { clearRefState, flushPendingRefs } from '../prop-adapters/ref.js';
import { __root } from '../runtime/page/root-instance.js';
import { resetElementTemplateBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';
import { resetElementTemplateMainThreadFunctionRuntime } from '../runtime/template/main-thread-function.js';
export function destroyElementTemplateBackgroundRuntime() {
    resetElementTemplateHydrationListener();
    cancelElementTemplateRemovedSubtreeCleanup();
    render(null, __root);
    // Run user cleanup before dropping the backend side tables; after clearRefState
    // the raw ref ownership needed to detach callbacks is gone.
    flushPendingRefs();
    resetElementTemplateCommitState();
    resetElementTemplateBackgroundFunctionRuntime();
    resetElementTemplateMainThreadFunctionRuntime();
    clearEventState();
    clearRefState();
    backgroundElementTemplateInstanceManager.clear();
}
//# sourceMappingURL=destroy.js.map