import { __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { useContext, useEffect } from 'react';
import styles from '@patternfly/react-styles/css/components/Page/page.mjs';
import { css } from '@patternfly/react-styles';
import { formatBreakpointMods } from '../../helpers/util';
import { PageContext } from './PageContext';
import { PageBody } from './PageBody';
export var PageSectionVariants;
(function (PageSectionVariants) {
    PageSectionVariants["default"] = "default";
    PageSectionVariants["secondary"] = "secondary";
})(PageSectionVariants || (PageSectionVariants = {}));
export var PageSectionTypes;
(function (PageSectionTypes) {
    PageSectionTypes["default"] = "default";
    PageSectionTypes["subNav"] = "subnav";
    PageSectionTypes["breadcrumb"] = "breadcrumb";
    PageSectionTypes["tabs"] = "tabs";
    PageSectionTypes["wizard"] = "wizard";
})(PageSectionTypes || (PageSectionTypes = {}));
const variantType = {
    [PageSectionTypes.default]: styles.pageMainSection,
    [PageSectionTypes.subNav]: styles.pageMainSubnav,
    [PageSectionTypes.breadcrumb]: styles.pageMainBreadcrumb,
    [PageSectionTypes.tabs]: styles.pageMainTabs,
    [PageSectionTypes.wizard]: styles.pageMainWizard
};
const variantStyle = {
    [PageSectionVariants.default]: '',
    [PageSectionVariants.secondary]: styles.modifiers.secondary
};
export const PageSection = (_a) => {
    var { className = '', children, variant = 'default', type = 'default', padding, isFilled, isWidthLimited = false, isCenterAligned = false, stickyOnBreakpoint, stickyBase, isStickyStuck = false, hasShadowTop = false, hasShadowBottom = false, hasOverflowScroll = false, 'aria-label': ariaLabel, component = 'section', hasBodyWrapper = true, isPlain = false, isNoPlainOnGlass = false } = _a, props = __rest(_a, ["className", "children", "variant", "type", "padding", "isFilled", "isWidthLimited", "isCenterAligned", "stickyOnBreakpoint", "stickyBase", "isStickyStuck", "hasShadowTop", "hasShadowBottom", "hasOverflowScroll", 'aria-label', "component", "hasBodyWrapper", "isPlain", "isNoPlainOnGlass"]);
    const { height, getVerticalBreakpoint } = useContext(PageContext);
    useEffect(() => {
        if (hasOverflowScroll && !ariaLabel) {
            /* eslint-disable no-console */
            console.warn('PageSection: An accessible aria-label is required when hasOverflowScroll is set to true.');
        }
    }, [hasOverflowScroll, ariaLabel]);
    const Component = component;
    return (_jsx(Component, Object.assign({}, props, { className: css(variantType[type], formatBreakpointMods(padding, styles), formatBreakpointMods(stickyOnBreakpoint, styles, 'sticky-', getVerticalBreakpoint(height), true), stickyBase === 'top' && styles.modifiers.stickyTopBase, stickyBase === 'bottom' && styles.modifiers.stickyBottomBase, isStickyStuck && stickyBase === 'top' && styles.modifiers.stickyTopStuck, isStickyStuck && stickyBase === 'bottom' && styles.modifiers.stickyBottomStuck, type === PageSectionTypes.default && variantStyle[variant], isFilled === false && styles.modifiers.noFill, isFilled === true && styles.modifiers.fill, isWidthLimited && styles.modifiers.limitWidth, isWidthLimited && isCenterAligned && type !== PageSectionTypes.subNav && styles.modifiers.alignCenter, hasShadowTop && styles.modifiers.shadowTop, hasShadowBottom && styles.modifiers.shadowBottom, hasOverflowScroll && styles.modifiers.overflowScroll, isPlain && styles.modifiers.plain, isNoPlainOnGlass && styles.modifiers.noPlainOnGlass, className) }, (hasOverflowScroll && { tabIndex: 0 }), { "aria-label": ariaLabel, children: hasBodyWrapper ? _jsx(PageBody, { children: children }) : children })));
};
PageSection.displayName = 'PageSection';
//# sourceMappingURL=PageSection.js.map