import { jsxs as m, jsx as n } from "react/jsx-runtime";
import { useRef as V, useCallback as f } from "react";
import { VariableSizeList as _ } from "../../shop-minis-react/node_modules/.pnpm/react-window@1.8.11_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-window/dist/index.esm.js";
import { cn as j } from "../../lib/utils.js";
/* empty css                         */
import { Pagination as C } from "./pagination.js";
const N = _;
function q({
  items: t,
  height: p,
  renderItem: o,
  className: v,
  showScrollbar: b = !1,
  header: i,
  headerHeight: c,
  itemSizeForRow: a,
  fetchMore: l,
  overscanCount: g,
  ...h
}) {
  const s = V(null), e = f(() => {
    if (s.current) return;
    const r = Promise.resolve(l?.()).finally(() => {
      s.current === r && (s.current = null);
    });
    s.current = r;
  }, [l]), L = f(
    ({ index: r, style: u }) => i && r === 0 ? /* @__PURE__ */ m("div", { style: u, children: [
      i,
      /* @__PURE__ */ n("div", { style: { top: c }, children: o(t[0], 0) })
    ] }) : l && r === t.length - 1 ? /* @__PURE__ */ m("div", { style: u, children: [
      o(t[r], r),
      /* @__PURE__ */ n("div", { style: { bottom: 0 }, children: /* @__PURE__ */ n(C, { fetchMore: e }) })
    ] }) : /* @__PURE__ */ n("div", { style: u, children: o(t[r], r) }),
    [t, o, i, c, e, l]
  ), z = f(
    (r) => i && r === 0 ? (c || 0) + a(r) : a(r),
    [a, i, c]
  ), S = j(b ? void 0 : "no-scrollbars", v);
  return /* @__PURE__ */ n(
    N,
    {
      className: S,
      height: p,
      direction: "vertical",
      width: "100%",
      itemCount: t.length,
      overscanCount: g,
      itemSize: z,
      ...h,
      children: L
    }
  );
}
export {
  q as List
};
//# sourceMappingURL=list.js.map
