import { resetComponent as S, genFocusStyle as b } from "../../style/index.mjs";
import { initMoveMotion as v } from "../../style/motion/move.mjs";
import { slideUpIn as h, slideDownIn as z, slideUpOut as x, slideDownOut as y, initSlideMotion as w } from "../../style/motion/slide.mjs";
import { initZoomMotion as C } from "../../style/motion/zoom.mjs";
import I, { getArrowOffsetToken as R } from "../../style/placementArrow.mjs";
import "../../../../@ant-design/cssinjs/es/extractStyle.mjs";
import "../../../../@ant-design/cssinjs/es/hooks/useCacheToken.mjs";
import "react";
import "../../../../@ant-design/cssinjs/es/StyleContext.mjs";
import { unit as n } from "../../../../@ant-design/cssinjs/es/util/index.mjs";
import "../../../../@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.mjs";
import "../../../../@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.mjs";
import "../../../../@ant-design/cssinjs/es/hooks/useHMR.mjs";
import "../../../../rc-util/es/warning.mjs";
import "../../../../@ant-design/cssinjs/es/theme/createTheme.mjs";
import "../../../../@ant-design/cssinjs/es/theme/ThemeCache.mjs";
import "../../../../@ant-design/cssinjs/es/transformers/legacyLogicalProperties.mjs";
import { genStyleHooks as O } from "../../theme/util/genComponentStyleHook.mjs";
import { merge as P } from "../../theme/util/statistic.mjs";
import A from "./status.mjs";
import { getArrowToken as B } from "../../style/roundedArrow.mjs";
const D = (e) => {
  const {
    componentCls: i,
    menuCls: t,
    zIndexPopup: a,
    dropdownArrowDistance: s,
    sizePopupArrow: l,
    antCls: o,
    iconCls: r,
    motionDurationMid: d,
    paddingBlock: $,
    fontSize: g,
    dropdownEdgeChildPadding: f,
    colorTextDisabled: m,
    fontSizeIcon: c,
    controlPaddingHorizontal: u,
    colorBgElevated: p
  } = e;
  return [
    {
      [i]: Object.assign(Object.assign({}, S(e)), {
        position: "absolute",
        top: -9999,
        left: {
          _skip_check_: !0,
          value: -9999
        },
        zIndex: a,
        display: "block",
        // A placeholder out of dropdown visible range to avoid close when user moving
        "&::before": {
          position: "absolute",
          insetBlock: e.calc(l).div(2).sub(s).equal(),
          // insetInlineStart: -7, // FIXME: Seems not work for hidden element
          zIndex: -9999,
          opacity: 1e-4,
          content: '""'
        },
        [`&-trigger${o}-btn`]: {
          [`& > ${r}-down, & > ${o}-btn-icon > ${r}-down`]: {
            fontSize: c
          }
        },
        [`${i}-wrap`]: {
          position: "relative",
          [`${o}-btn > ${r}-down`]: {
            fontSize: c
          },
          [`${r}-down::before`]: {
            transition: `transform ${d}`
          }
        },
        [`${i}-wrap-open`]: {
          [`${r}-down::before`]: {
            transform: "rotate(180deg)"
          }
        },
        "\n        &-hidden,\n        &-menu-hidden,\n        &-menu-submenu-hidden\n      ": {
          display: "none"
        },
        // =============================================================
        // ==                         Motion                          ==
        // =============================================================
        // When position is not enough for dropdown, the placement will revert.
        // We will handle this with revert motion name.
        [`&${o}-slide-down-enter${o}-slide-down-enter-active${i}-placement-bottomLeft,
          &${o}-slide-down-appear${o}-slide-down-appear-active${i}-placement-bottomLeft,
          &${o}-slide-down-enter${o}-slide-down-enter-active${i}-placement-bottom,
          &${o}-slide-down-appear${o}-slide-down-appear-active${i}-placement-bottom,
          &${o}-slide-down-enter${o}-slide-down-enter-active${i}-placement-bottomRight,
          &${o}-slide-down-appear${o}-slide-down-appear-active${i}-placement-bottomRight`]: {
          animationName: h
        },
        [`&${o}-slide-up-enter${o}-slide-up-enter-active${i}-placement-topLeft,
          &${o}-slide-up-appear${o}-slide-up-appear-active${i}-placement-topLeft,
          &${o}-slide-up-enter${o}-slide-up-enter-active${i}-placement-top,
          &${o}-slide-up-appear${o}-slide-up-appear-active${i}-placement-top,
          &${o}-slide-up-enter${o}-slide-up-enter-active${i}-placement-topRight,
          &${o}-slide-up-appear${o}-slide-up-appear-active${i}-placement-topRight`]: {
          animationName: z
        },
        [`&${o}-slide-down-leave${o}-slide-down-leave-active${i}-placement-bottomLeft,
          &${o}-slide-down-leave${o}-slide-down-leave-active${i}-placement-bottom,
          &${o}-slide-down-leave${o}-slide-down-leave-active${i}-placement-bottomRight`]: {
          animationName: x
        },
        [`&${o}-slide-up-leave${o}-slide-up-leave-active${i}-placement-topLeft,
          &${o}-slide-up-leave${o}-slide-up-leave-active${i}-placement-top,
          &${o}-slide-up-leave${o}-slide-up-leave-active${i}-placement-topRight`]: {
          animationName: y
        }
      })
    },
    // =============================================================
    // ==                        Arrow style                      ==
    // =============================================================
    I(e, p, {
      arrowPlacement: {
        top: !0,
        bottom: !0
      }
    }),
    {
      // =============================================================
      // ==                          Menu                           ==
      // =============================================================
      [`${i} ${t}`]: {
        position: "relative",
        margin: 0
      },
      [`${t}-submenu-popup`]: {
        position: "absolute",
        zIndex: a,
        background: "transparent",
        boxShadow: "none",
        transformOrigin: "0 0",
        "ul, li": {
          listStyle: "none",
          margin: 0
        }
      },
      [`${i}, ${i}-menu-submenu`]: {
        [t]: Object.assign(Object.assign({
          padding: f,
          listStyleType: "none",
          backgroundColor: p,
          backgroundClip: "padding-box",
          borderRadius: e.borderRadiusLG,
          outline: "none",
          boxShadow: e.boxShadowSecondary
        }, b(e)), {
          [`${t}-item-group-title`]: {
            padding: `${n($)} ${n(u)}`,
            color: e.colorTextDescription,
            transition: `all ${d}`
          },
          // ======================= Item Content =======================
          [`${t}-item`]: {
            position: "relative",
            display: "flex",
            alignItems: "center"
          },
          [`${t}-item-icon`]: {
            minWidth: g,
            marginInlineEnd: e.marginXS,
            fontSize: e.fontSizeSM
          },
          [`${t}-title-content`]: {
            flex: "auto",
            "> a": {
              color: "inherit",
              transition: `all ${d}`,
              "&:hover": {
                color: "inherit"
              },
              "&::after": {
                position: "absolute",
                inset: 0,
                content: '""'
              }
            }
          },
          // =========================== Item ===========================
          [`${t}-item, ${t}-submenu-title`]: Object.assign(Object.assign({
            clear: "both",
            margin: 0,
            padding: `${n($)} ${n(u)}`,
            color: e.colorText,
            fontWeight: "normal",
            fontSize: g,
            lineHeight: e.lineHeight,
            cursor: "pointer",
            transition: `all ${d}`,
            borderRadius: e.borderRadiusSM,
            "&:hover, &-active": {
              backgroundColor: e.controlItemBgHover
            }
          }, b(e)), {
            "&-selected": {
              color: e.colorPrimary,
              backgroundColor: e.controlItemBgActive,
              "&:hover, &-active": {
                backgroundColor: e.controlItemBgActiveHover
              }
            },
            "&-disabled": {
              color: m,
              cursor: "not-allowed",
              "&:hover": {
                color: m,
                backgroundColor: p,
                cursor: "not-allowed"
              },
              a: {
                pointerEvents: "none"
              }
            },
            "&-divider": {
              height: 1,
              // By design
              margin: `${n(e.marginXXS)} 0`,
              overflow: "hidden",
              lineHeight: 0,
              backgroundColor: e.colorSplit
            },
            [`${i}-menu-submenu-expand-icon`]: {
              position: "absolute",
              insetInlineEnd: e.paddingXS,
              [`${i}-menu-submenu-arrow-icon`]: {
                marginInlineEnd: "0 !important",
                color: e.colorTextDescription,
                fontSize: c,
                fontStyle: "normal"
              }
            }
          }),
          [`${t}-item-group-list`]: {
            margin: `0 ${n(e.marginXS)}`,
            padding: 0,
            listStyle: "none"
          },
          [`${t}-submenu-title`]: {
            paddingInlineEnd: e.calc(u).add(e.fontSizeSM).equal()
          },
          [`${t}-submenu-vertical`]: {
            position: "relative"
          },
          [`${t}-submenu${t}-submenu-disabled ${i}-menu-submenu-title`]: {
            [`&, ${i}-menu-submenu-arrow-icon`]: {
              color: m,
              backgroundColor: p,
              cursor: "not-allowed"
            }
          },
          // https://github.com/ant-design/ant-design/issues/19264
          [`${t}-submenu-selected ${i}-menu-submenu-title`]: {
            color: e.colorPrimary
          }
        })
      }
    },
    // Follow code may reuse in other components
    [w(e, "slide-up"), w(e, "slide-down"), v(e, "move-up"), v(e, "move-down"), C(e, "zoom-big")]
  ];
}, H = (e) => Object.assign(Object.assign({
  zIndexPopup: e.zIndexPopupBase + 50,
  paddingBlock: (e.controlHeight - e.fontSize * e.lineHeight) / 2
}, R({
  contentRadius: e.borderRadiusLG,
  limitVerticalRadius: !0
})), B(e)), oe = O("Dropdown", (e) => {
  const {
    marginXXS: i,
    sizePopupArrow: t,
    paddingXXS: a,
    componentCls: s
  } = e, l = P(e, {
    menuCls: `${s}-menu`,
    dropdownArrowDistance: e.calc(t).div(2).add(i).equal(),
    dropdownEdgeChildPadding: a
  });
  return [D(l), A(l)];
}, H);
export {
  oe as default,
  H as prepareComponentToken
};
