import { useState as d, useLayoutEffect as f } from "react";
const w = 280, R = 16;
function A(r, n = w, t = R) {
  const [a, s] = d(1);
  return f(() => {
    const e = r.current;
    if (!e)
      return;
    const c = (o) => Math.max(1, Math.floor((o + t) / (n + t))), i = e.getBoundingClientRect().width;
    i > 0 && s(c(i));
    const u = new ResizeObserver(([o]) => {
      s(c(o.contentRect.width));
    });
    return u.observe(e), () => u.disconnect();
  }, [r, n, t]), a;
}
export {
  A as useCardsPerRow
};
