import { jsxs as c, jsx as t } from "react/jsx-runtime";
import I, { forwardRef as O, useState as x, useRef as h, useImperativeHandle as _, useEffect as T } from "react";
import { debounce as k } from "es-toolkit/compat";
import a from "../../utils/classNames.js";
import F from "../smoothScrollbars/SmoothScrollbars.js";
const P = 200, j = 54, Z = O((y, g) => {
  const {
    className: N,
    innerClassName: i,
    forceScrollbar: b = !0,
    enableScrollToTop: B = !0,
    banner: p,
    navigation: m,
    bottomBar: e,
    bottomBarHeight: u = j,
    scrollResetTrigger: S,
    children: H,
    ...L
  } = y, [R, s] = x(0), o = h(null), r = h(null);
  _(g, () => r?.current, []), T(() => {
    o.current && (o.current.scrollTop(0), s(0));
  }, [S]), T(() => {
    r.current?.parentNode instanceof HTMLElement && (e ? r.current.parentNode.style.setProperty(
      "--ApplicationLayoutBodyBottomBarHeight",
      `${u}px`
    ) : r.current.parentNode.style.removeProperty("--ApplicationLayoutBodyBottomBarHeight"));
  }, [e, u]);
  const E = k(() => {
    o.current && s(o.current.getScrollTop());
  }, P), d = () => {
    if (!o.current)
      return;
    const l = o.current.container, f = l.firstElementChild, n = f?.scrollTop ?? 0;
    n > 10 ? (window.requestAnimationFrame(d), f?.scrollTo(0, n - n / 5), l.classList.add("is-scrolling-to-top"), s(n)) : l.classList.remove("is-scrolling-to-top");
  }, v = a("ApplicationLayoutBody", e ? "has-footer" : "", N), w = a(
    "module-content",
    i && i
  ), A = window.innerHeight * 0.1, C = a("scroll-to-top", R > A && "in");
  return /* @__PURE__ */ c(I.Fragment, { children: [
    /* @__PURE__ */ c("div", { ...L, ref: r, className: v, children: [
      /* @__PURE__ */ c("div", { className: "module-content-wrapper", children: [
        m && m,
        p && p,
        /* @__PURE__ */ t(
          F,
          {
            ref: o,
            slideIn: !b,
            largeTrack: !0,
            trackOffset: !0,
            className: w,
            onScroll: E,
            children: /* @__PURE__ */ t("div", { className: "scrollbar-content", children: H })
          }
        )
      ] }),
      B && /* @__PURE__ */ t("span", { className: C, children: /* @__PURE__ */ t("button", { type: "button", className: "btn btn-primary btn-icon-only", onClick: d, children: /* @__PURE__ */ t("span", { className: "rioglyph rioglyph-arrow-up" }) }) })
    ] }),
    e && e
  ] });
});
export {
  Z as default
};
//# sourceMappingURL=ApplicationLayoutBody.js.map
