"use client";
import * as r from "react";
import { flushSync as c } from "react-dom";
import { Virtualizer as f, elementScroll as i, observeElementOffset as m, observeElementRect as d } from "../../../virtual-core/dist/esm/index.js";
import { defaultKeyExtractor as R, defaultRangeExtractor as g, measureElement as z } from "../../../virtual-core/dist/esm/index.js";
const l = typeof document < "u" ? r.useLayoutEffect : r.useEffect;
function p(e) {
  const n = r.useReducer(() => ({}), {})[1], o = {
    ...e,
    onChange: (a, u) => {
      var s;
      u ? c(n) : n(), (s = e.onChange) == null || s.call(e, a, u);
    }
  }, [t] = r.useState(
    () => new f(o)
  );
  return t.setOptions(o), l(() => t._didMount(), []), l(() => t._willUpdate()), t;
}
function h(e) {
  return p({
    observeElementRect: d,
    observeElementOffset: m,
    scrollToFn: i,
    ...e
  });
}
export {
  f as Virtualizer,
  R as defaultKeyExtractor,
  g as defaultRangeExtractor,
  i as elementScroll,
  z as measureElement,
  m as observeElementOffset,
  d as observeElementRect,
  h as useVirtualizer
};
