"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const index$1 = require("../../icons/index.cjs");
;/* empty css                                                                                                                                                                                        */
;/* empty css                                                                                                                                                                                         */
;/* empty css                                                                                                                                                                                                 */
;/* empty css                                                                                                                                                                                            */
;/* empty css                                                                                                                                                                                            */
const index = require("../../primitive/Typography/index.cjs");
const clsx = require("clsx");
const styles = require("../../utils/styles.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 Group = 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/Group/Group.cjs");
const ActionIcon = 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/ActionIcon/ActionIcon.cjs");
const PageHeader = ({ sticky, leftSection, rightSection, children, ...restProps }) => {
  const rightExisted = !!rightSection;
  return /* @__PURE__ */ jsxRuntime.jsxs(
    Group.Group,
    {
      ...restProps,
      className: clsx.clsx(restProps == null ? void 0 : restProps.className, "pageshell-header"),
      wrap: "nowrap",
      justify: "space-between",
      gap: "xl",
      sx: styles.mergeSxList([
        {
          paddingLeft: 24,
          paddingRight: 24,
          height: 64
        },
        sticky ? (theme) => ({
          position: "sticky",
          zIndex: 1,
          top: 0,
          left: 0,
          background: theme.other.white
        }) : void 0,
        restProps.sx
      ]),
      children: [
        /* @__PURE__ */ jsxRuntime.jsxs(Group.Group, { wrap: "nowrap", children: [
          leftSection,
          /* @__PURE__ */ jsxRuntime.jsx(index.Typography, { variant: "headline-lg", component: "div", fw: 300, sx: { flex: 1 }, children })
        ] }),
        rightExisted && /* @__PURE__ */ jsxRuntime.jsx(Group.Group, { gap: 0, wrap: "nowrap", children: rightSection })
      ]
    }
  );
};
const PageShell = ({
  className,
  headerClassName,
  bodyClassName,
  headerSticky,
  headerRightSection,
  headerBack,
  title,
  wrapped = false,
  wrapperProps = {},
  headerProps: { withBack, onBackClick, ...headerProps } = {},
  bodyProps = {},
  children
}) => {
  const headerVisible = !!title || !!headerRightSection;
  const leftSection = (!!withBack || !!headerBack) && /* @__PURE__ */ jsxRuntime.jsx(
    ActionIcon.ActionIcon,
    {
      "aria-label": "Navigate Back",
      variant: "default",
      onClick: () => {
        if (onBackClick) {
          onBackClick();
        } else if (typeof headerBack === "function") {
          headerBack();
        } else {
          history.back();
        }
      },
      children: /* @__PURE__ */ jsxRuntime.jsx(index$1.IconChevronLeft, { size: 20 })
    }
  );
  const page = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
    headerVisible && /* @__PURE__ */ jsxRuntime.jsx(
      PageHeader,
      {
        className: headerClassName,
        sticky: headerSticky,
        leftSection,
        rightSection: headerRightSection,
        ...headerProps,
        children: title
      }
    ),
    /* @__PURE__ */ jsxRuntime.jsx(
      Box.Box,
      {
        ...bodyProps,
        className: clsx.clsx(bodyClassName, bodyProps == null ? void 0 : bodyProps.className, "pageshell-body"),
        sx: styles.mergeSxList([
          {
            paddingLeft: 24,
            paddingRight: 24,
            paddingBottom: 16,
            paddingTop: headerVisible ? 0 : 16
          },
          bodyProps == null ? void 0 : bodyProps.sx
        ]),
        children
      }
    )
  ] });
  if (wrapped) {
    return /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ...wrapperProps, className: clsx.clsx(className, wrapperProps == null ? void 0 : wrapperProps.className, "pageshell-wrapper"), children: page });
  }
  return page;
};
PageShell.Header = PageHeader;
exports.PageShell = PageShell;
