import { useState as m, useEffect as E, useMemo as g } from "react";
import { MAX_LIST_VIEW_AREA_HEIGHT as o, MIN_LIST_VIEW_AREA_HEIGHT as d, LIST_CONTAINER_ID as h, TX_ITEM_HEIGHT as a } from "./constants.js";
const l = ({
  transactionsCount: i,
  hasNextPage: n,
  isVisible: r
}) => {
  const [s, w] = m(
    o
  );
  return E(() => {
    if (!r)
      return;
    const e = () => {
      const t = document.getElementById(h);
      if (!t)
        return;
      const H = (window.visualViewport?.height ?? window.innerHeight) - t.getBoundingClientRect().top - 24;
      w(
        Math.max(
          d,
          Math.min(o, H)
        )
      );
    };
    return e(), window.addEventListener("resize", e), window.visualViewport?.addEventListener(
      "resize",
      e
    ), () => {
      window.removeEventListener("resize", e), window.visualViewport?.removeEventListener(
        "resize",
        e
      );
    };
  }, [i, n, r]), g(() => {
    const e = n ? a : 0, t = i * a + e;
    return Math.max(
      d,
      Math.min(o, s, t)
    );
  }, [s, n, i]);
};
export {
  l as useTransactionHistoryListHeight
};
//# sourceMappingURL=useTransactionHistoryListHeight.js.map
