"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
;/* empty css                                                                                                                                                                                        */
;/* empty css                                                                                                                                                                                         */
;/* empty css                                                                                                                                                                                                 */
;/* empty css                                                                                                                                                                                            */
;/* empty css                                                                                                                                                                                            */
const AppShellBody = require("./container/AppShellBody.cjs");
const AppShellMain = require("./container/AppShellMain.cjs");
const AppShellRoot = require("./container/AppShellRoot.cjs");
const navMenuRefContext = require("./navbar/context/nav-menu-ref-context.cjs");
const ExpandNavbarButton = require("./navbar/ExpandNavbarButton.cjs");
const Navbar = require("./navbar/Navbar.cjs");
const NavbarHeader = require("./navbar/NavbarHeader.cjs");
const NavbarSection = require("./navbar/NavbarSection.cjs");
const Box = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/core/Box/Box.cjs");
const Stack = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/components/Stack/Stack.cjs");
const Divider = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/components/Divider/Divider.cjs");
const DEFAULT_NAVBAR_WIDTH = 240;
const AppShell = ({ banner, navbar, children }) => {
  const navMenuRef = React.useRef(null);
  const bannerRef = React.useRef(null);
  const [withBanner, setWithBanner] = React.useState(false);
  const [navbarCollapsed, setNavbarCollapsed] = React.useState(false);
  const navbarWidth = navbar.width ?? DEFAULT_NAVBAR_WIDTH;
  const toggleNavbar = React.useCallback(() => {
    setNavbarCollapsed((prev) => !prev);
  }, []);
  React.useEffect(() => {
    var _a;
    if (bannerRef.current) {
      setWithBanner(((_a = bannerRef.current.children) == null ? void 0 : _a.length) > 0);
    }
  }, [banner]);
  return /* @__PURE__ */ jsxRuntime.jsxs(AppShellRoot.AppShellRoot, { children: [
    /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ref: bannerRef, children: banner }),
    /* @__PURE__ */ jsxRuntime.jsxs(
      AppShellMain.AppShellMain,
      {
        mod: withBanner ? ["height-flex"] : void 0,
        style: {
          "--app-shell-transition-duration": "200ms",
          "--app-shell-transition-timing-function": "ease",
          "--app-shell-navbar-width": `${navbarWidth}px`,
          "--app-shell-navbar-offset": navbarCollapsed ? "0px" : `${navbarWidth}px`,
          "--app-shell-navbar-collapsed": navbarCollapsed ? "1" : "0"
        },
        children: [
          navbarCollapsed && /* @__PURE__ */ jsxRuntime.jsx(ExpandNavbarButton.ExpandNavbarButton, { onClick: toggleNavbar }),
          /* @__PURE__ */ jsxRuntime.jsxs(Navbar.Navbar, { withBorder: true, hidden: navbarCollapsed, children: [
            /* @__PURE__ */ jsxRuntime.jsx(NavbarSection.NavbarSection, { children: /* @__PURE__ */ jsxRuntime.jsx(
              NavbarHeader.NavbarHeader,
              {
                logo: navbar.logo,
                onLogoClick: navbar.onLogoClick,
                onToggleCollapse: toggleNavbar,
                px: "md",
                py: 8
              }
            ) }),
            /* @__PURE__ */ jsxRuntime.jsx(NavbarSection.NavbarSection, { children: /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { px: "md", children: navbar.resourceShortcut }) }),
            /* @__PURE__ */ jsxRuntime.jsx(NavbarSection.NavbarSection, { grow: true, scrollable: true, py: 8, children: /* @__PURE__ */ jsxRuntime.jsx(Stack.Stack, { ref: navMenuRef, gap: 8, px: "md" }) }),
            /* @__PURE__ */ jsxRuntime.jsxs(NavbarSection.NavbarSection, { px: "md", py: "8", children: [
              /* @__PURE__ */ jsxRuntime.jsx(Divider.Divider, { mx: "-md", mb: 8 }),
              /* @__PURE__ */ jsxRuntime.jsx(Stack.Stack, { gap: 8, children: navbar.footer })
            ] })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsx(AppShellBody.AppShellBody, { children: /* @__PURE__ */ jsxRuntime.jsx(navMenuRefContext.NavMenuRefContext.Provider, { value: navMenuRef, children }) })
        ]
      }
    )
  ] });
};
exports.AppShell = AppShell;
