"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const virtualCore = require("@tanstack/virtual-core"); class VirtualizerControllerBase { constructor(host, options) { this.cleanup = () => { }; (this.host = host).addController(this); const resolvedOptions = { ...options, onChange: (instance, sync) => { var _a; this.host.updateComplete.then(() => this.host.requestUpdate()); (_a = options.onChange) == null ? void 0 : _a.call(options, instance, sync); } }; this.virtualizer = new virtualCore.Virtualizer(resolvedOptions); } getVirtualizer() { return this.virtualizer; } async hostConnected() { this.cleanup = this.virtualizer._didMount(); } hostUpdated() { this.virtualizer._willUpdate(); } hostDisconnected() { this.cleanup(); } } class VirtualizerController extends VirtualizerControllerBase { constructor(host, options) { super(host, { observeElementRect: virtualCore.observeElementRect, observeElementOffset: virtualCore.observeElementOffset, scrollToFn: virtualCore.elementScroll, ...options }); } } class WindowVirtualizerController extends VirtualizerControllerBase { constructor(host, options) { super(host, { getScrollElement: () => typeof document !== "undefined" ? window : null, observeElementRect: virtualCore.observeWindowRect, observeElementOffset: virtualCore.observeWindowOffset, scrollToFn: virtualCore.windowScroll, initialOffset: () => typeof document !== "undefined" ? window.scrollY : 0, ...options }); } } exports.VirtualizerController = VirtualizerController; exports.WindowVirtualizerController = WindowVirtualizerController; //# sourceMappingURL=index.cjs.map