"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _internal = require("../../theme/internal");
var _motion = _interopRequireDefault(require("./motion"));
var _style = require("../../style");
// =============================== Base ===============================
const genDrawerStyle = token => {
  const {
    componentCls,
    zIndexPopup,
    colorBgMask,
    colorBgElevated,
    motionDurationSlow,
    motionDurationMid,
    padding,
    paddingLG,
    fontSizeLG,
    lineHeightLG,
    lineWidth,
    lineType,
    colorSplit,
    marginSM,
    colorIcon,
    colorIconHover,
    colorText,
    fontWeightStrong,
    drawerFooterPaddingVertical,
    drawerFooterPaddingHorizontal,
    draggerSize
  } = token;
  const wrapperCls = `${componentCls}-content-wrapper`;
  const draggerCls = `${componentCls}-resizable-dragger`;
  return {
    [componentCls]: {
      position: 'fixed',
      inset: 0,
      zIndex: zIndexPopup,
      pointerEvents: 'none',
      '&-pure': {
        position: 'relative',
        background: colorBgElevated,
        [`&${componentCls}-left`]: {
          boxShadow: token.boxShadowDrawerLeft
        },
        [`&${componentCls}-right`]: {
          boxShadow: token.boxShadowDrawerRight
        },
        [`&${componentCls}-top`]: {
          boxShadow: token.boxShadowDrawerUp
        },
        [`&${componentCls}-bottom`]: {
          boxShadow: token.boxShadowDrawerDown
        }
      },
      '&-inline': {
        position: 'absolute'
      },
      // ====================== Mask ======================
      [`${componentCls}-mask`]: {
        position: 'absolute',
        inset: 0,
        zIndex: zIndexPopup,
        background: colorBgMask,
        pointerEvents: 'auto',
        [`&${componentCls}-mask-blur`]: (0, _extends2.default)({}, _style.blurMaskStyle)
      },
      // ==================== Content =====================
      [wrapperCls]: {
        position: 'absolute',
        zIndex: zIndexPopup,
        transition: `all ${motionDurationSlow}`,
        '&-hidden': {
          display: 'none'
        }
      },
      // Placement
      [`&-left > ${wrapperCls}`]: {
        top: 0,
        bottom: 0,
        left: {
          _skip_check_: true,
          value: 0
        },
        boxShadow: token.boxShadowDrawerLeft
      },
      [`&-right > ${wrapperCls}`]: {
        top: 0,
        right: {
          _skip_check_: true,
          value: 0
        },
        bottom: 0,
        boxShadow: token.boxShadowDrawerRight
      },
      [`&-top > ${wrapperCls}`]: {
        top: 0,
        insetInline: 0,
        boxShadow: token.boxShadowDrawerUp
      },
      [`&-bottom > ${wrapperCls}`]: {
        bottom: 0,
        insetInline: 0,
        boxShadow: token.boxShadowDrawerDown
      },
      [`${componentCls}-content`]: {
        width: '100%',
        height: '100%',
        overflow: 'auto',
        background: colorBgElevated,
        pointerEvents: 'auto'
      },
      // ===================== Panel ======================
      [`${componentCls}-wrapper-body`]: {
        display: 'flex',
        flexDirection: 'column',
        width: '100%',
        height: '100%'
      },
      // Header
      [`${componentCls}-header`]: {
        display: 'flex',
        flex: 0,
        alignItems: 'center',
        padding: `${padding}px ${paddingLG}px`,
        fontSize: fontSizeLG,
        lineHeight: lineHeightLG,
        borderBottom: `${lineWidth}px ${lineType} ${colorSplit}`,
        '&-title': {
          display: 'flex',
          flex: 1,
          alignItems: 'center',
          minWidth: 0,
          minHeight: 0
        }
      },
      [`${componentCls}-extra`]: {
        flex: 'none'
      },
      [`${componentCls}-close`]: {
        display: 'inline-block',
        marginInlineEnd: marginSM,
        color: colorIcon,
        fontWeight: fontWeightStrong,
        fontSize: fontSizeLG,
        fontStyle: 'normal',
        lineHeight: 1,
        textAlign: 'center',
        textTransform: 'none',
        textDecoration: 'none',
        background: 'transparent',
        border: 0,
        outline: 0,
        cursor: 'pointer',
        transition: `color ${motionDurationMid}`,
        textRendering: 'auto',
        '&:focus, &:hover': {
          color: colorIconHover,
          textDecoration: 'none'
        }
      },
      [`${componentCls}-title`]: {
        flex: 1,
        margin: 0,
        color: colorText,
        fontWeight: token.fontWeightStrong,
        fontSize: fontSizeLG,
        lineHeight: lineHeightLG
      },
      // Body
      [`${componentCls}-body`]: {
        flex: 1,
        minWidth: 0,
        minHeight: 0,
        padding: paddingLG,
        overflow: 'auto',
        [`${componentCls}-body-skeleton`]: {
          width: '100%',
          height: '100%',
          display: 'flex',
          justifyContent: 'center'
        }
      },
      // Footer
      [`${componentCls}-footer`]: {
        flexShrink: 0,
        padding: `${drawerFooterPaddingVertical}px ${drawerFooterPaddingHorizontal}px`,
        borderTop: `${lineWidth}px ${lineType} ${colorSplit}`
      },
      [draggerCls]: {
        position: 'absolute',
        zIndex: 1,
        backgroundColor: 'transparent',
        userSelect: 'none',
        pointerEvents: 'auto',
        '&:hover': {
          backgroundColor: token.colorPrimary,
          opacity: 0.2
        },
        '&-dragging': {
          backgroundColor: token.colorPrimary,
          opacity: 0.3
        }
      },
      [`${draggerCls}-left`]: {
        top: 0,
        bottom: 0,
        insetInlineEnd: 0,
        width: draggerSize,
        cursor: 'col-resize'
      },
      [`${draggerCls}-right`]: {
        top: 0,
        bottom: 0,
        insetInlineStart: 0,
        width: draggerSize,
        cursor: 'col-resize'
      },
      [`${draggerCls}-top`]: {
        insetInline: 0,
        bottom: 0,
        height: draggerSize,
        cursor: 'row-resize'
      },
      [`${draggerCls}-bottom`]: {
        insetInline: 0,
        top: 0,
        height: draggerSize,
        cursor: 'row-resize'
      },
      [`${wrapperCls}-dragging`]: {
        userSelect: 'none',
        transition: 'none',
        willChange: 'width, height',
        [`${componentCls}-content`]: {
          pointerEvents: 'none'
        },
        [`${componentCls}-section`]: {
          pointerEvents: 'none'
        }
      },
      // ====================== RTL =======================
      '&-rtl': {
        direction: 'rtl'
      }
    }
  };
};
// ============================== Export ==============================
var _default = exports.default = (0, _internal.genComponentStyleHook)('Drawer', token => {
  const drawerToken = (0, _internal.mergeToken)(token, {
    drawerFooterPaddingVertical: token.paddingXS,
    drawerFooterPaddingHorizontal: token.padding,
    draggerSize: 4
  });
  return [genDrawerStyle(drawerToken), (0, _motion.default)(drawerToken)];
}, token => ({
  zIndexPopup: token.zIndexPopupBase
}));