'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _tslib = require('../../../../_virtual/_tslib.js');
var React = require('react');
var index$1 = require('../bottomSheetHeader/index.js');
var styles = require('../../styles.js');
var index$3 = require('../bottomSheetBody/index.js');
var index$4 = require('../bottomSheetFooter/index.js');
var index$2 = require('../bottomSheetImage/index.js');
var index = require('../../../../utils/index.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

const BottomSheetContent = (_a) => {
    var { headerTitle, headerContentModifiers, headerControlsModifiers, hasPullTab, icon, dismissAction, primaryAction, stackedActionButtons, pinnedFooter = false, pinnedHeader = false, hasBodyPadding = true, isOpened = false, shouldCloseOnEsc = true, shouldCloseOnOverlayClick = true, children, bottomSheetRoot, height, width, imgValues, position = 'center', onClose, customHeader, customFooter, onPullTabClick, bodyRef } = _a, props = _tslib.__rest(_a, ["headerTitle", "headerContentModifiers", "headerControlsModifiers", "hasPullTab", "icon", "dismissAction", "primaryAction", "stackedActionButtons", "pinnedFooter", "pinnedHeader", "hasBodyPadding", "isOpened", "shouldCloseOnEsc", "shouldCloseOnOverlayClick", "children", "bottomSheetRoot", "height", "width", "imgValues", "position", "onClose", "customHeader", "customFooter", "onPullTabClick", "bodyRef"]);
    const [bottomSheetHeight, setBottomSheetHeight] = React.useState(height);
    const appendId = index.getId(props['id']);
    const expandBottomSheet = () => setBottomSheetHeight((prevState) => prevState === '100%' ? height : '100%');
    return (React__default['default'].createElement(styles.BottomSheetWrapper, { isOpened: isOpened, height: bottomSheetHeight, width: width, hasPullTab: hasPullTab, stackedActionButtons: stackedActionButtons, position: position, "data-testid": `${props['data-testid']}-bottom-sheet-wrapper`, id: appendId('wrapper') },
        React__default['default'].createElement(styles.MainContentWrapper, { id: appendId('wrapper') },
            hasPullTab && (React__default['default'].createElement(styles.PullTab, { hasPullTab: hasPullTab, onClick: onPullTabClick || expandBottomSheet, "data-testid": `${props['data-testid']}-bottom-sheet-pull-tab`, id: appendId('pull-tab') })),
            (headerContentModifiers === 'empty' &&
                headerControlsModifiers === 'default') ||
                (imgValues === null || imgValues === void 0 ? void 0 : imgValues.asHeader) ||
                customHeader !== undefined ? null : (React__default['default'].createElement(index$1.BottomSheetHeader, { headerTitle: headerTitle, onClose: onClose, hasPullTab: hasPullTab, headerContentModifiers: headerContentModifiers, headerControlsModifiers: headerControlsModifiers, pinnedHeader: pinnedHeader, icon: icon, "data-testid": props['data-testid'], "data-trackid": props['data-trackid'], "aria-label": props['aria-label'], id: appendId('header') })),
            customHeader && (React__default['default'].createElement(styles.CustomHeaderWrapper, { id: appendId('custom-header-wrapper') }, customHeader)),
            (imgValues === null || imgValues === void 0 ? void 0 : imgValues.imgSrc) && (imgValues === null || imgValues === void 0 ? void 0 : imgValues.asHeader) && (React__default['default'].createElement(index$2['default'], { imgValues: imgValues, onClose: onClose, headerControlsModifiers: headerControlsModifiers })),
            React__default['default'].createElement(styles.InnerWrapper, { pinnedHeader: pinnedHeader, pinnedFooter: pinnedFooter, id: appendId('inner-wrapper') },
                (imgValues === null || imgValues === void 0 ? void 0 : imgValues.imgSrc) && !(imgValues === null || imgValues === void 0 ? void 0 : imgValues.asHeader) && (React__default['default'].createElement(index$2['default'], { imgValues: imgValues, onClose: onClose, headerControlsModifiers: headerControlsModifiers })),
                children && (React__default['default'].createElement(index$3.BottomSheetBody, { pinnedFooter: pinnedFooter, dismissAction: dismissAction, stackedActionButtons: stackedActionButtons, hasBodyPadding: hasBodyPadding, "data-testid": props['data-testid'], "data-trackid": props['data-trackid'], "aria-label": props['aria-label'], bodyRef: bodyRef, id: appendId('body') }, children)),
                primaryAction && !customFooter && (React__default['default'].createElement(index$4.BottomSheetFooter, { primaryAction: primaryAction, dismissAction: dismissAction, stackedActionButtons: stackedActionButtons, pinnedFooter: pinnedFooter, "data-testid": props['data-testid'], "data-trackid": props['data-trackid'], "aria-label": props['aria-label'], id: appendId('footer') })),
                customFooter))));
};

exports.BottomSheetContent = BottomSheetContent;
