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 l } 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 { clearFix as x, resetComponent as j, resetIcon as k } from "../../style/index.mjs";
import { initSlideMotion as D } from "../../style/motion/slide.mjs";
import { initZoomMotion as W } from "../../style/motion/zoom.mjs";
import L from "../../style/motion/collapse.mjs";
import { genStyleHooks as E } from "../../theme/util/genComponentStyleHook.mjs";
import { merge as y } from "../../theme/util/statistic.mjs";
import X from "./horizontal.mjs";
import q from "./rtl.mjs";
import w from "./theme.mjs";
import G from "./vertical.mjs";
import { TinyColor as A } from "../../../../@ctrl/tinycolor/dist/module/index.mjs";
const M = (t) => {
  const {
    componentCls: r,
    motionDurationSlow: e,
    motionDurationMid: n,
    motionEaseInOut: o,
    motionEaseOut: a,
    iconCls: i,
    iconSize: d,
    iconMarginInlineEnd: c
  } = t;
  return {
    // >>>>> Item
    [`${r}-item, ${r}-submenu-title`]: {
      position: "relative",
      display: "block",
      margin: 0,
      whiteSpace: "nowrap",
      cursor: "pointer",
      transition: [`border-color ${e}`, `background ${e}`, `padding ${e} ${o}`].join(","),
      [`${r}-item-icon, ${i}`]: {
        minWidth: d,
        fontSize: d,
        transition: [`font-size ${n} ${a}`, `margin ${e} ${o}`, `color ${e}`].join(","),
        "+ span": {
          marginInlineStart: c,
          opacity: 1,
          transition: [`opacity ${e} ${o}`, `margin ${e}`, `color ${e}`].join(",")
        }
      },
      [`${r}-item-icon`]: Object.assign({}, k()),
      [`&${r}-item-only-child`]: {
        [`> ${i}, > ${r}-item-icon`]: {
          marginInlineEnd: 0
        }
      }
    },
    // Disabled state sets text to gray and nukes hover/tab effects
    [`${r}-item-disabled, ${r}-submenu-disabled`]: {
      background: "none !important",
      cursor: "not-allowed",
      "&::after": {
        borderColor: "transparent !important"
      },
      a: {
        color: "inherit !important"
      },
      [`> ${r}-submenu-title`]: {
        color: "inherit !important",
        cursor: "not-allowed"
      }
    }
  };
}, O = (t) => {
  const {
    componentCls: r,
    motionDurationSlow: e,
    motionEaseInOut: n,
    borderRadius: o,
    menuArrowSize: a,
    menuArrowOffset: i
  } = t;
  return {
    [`${r}-submenu`]: {
      "&-expand-icon, &-arrow": {
        position: "absolute",
        top: "50%",
        insetInlineEnd: t.margin,
        width: a,
        color: "currentcolor",
        transform: "translateY(-50%)",
        transition: `transform ${e} ${n}, opacity ${e}`
      },
      "&-arrow": {
        // →
        "&::before, &::after": {
          position: "absolute",
          width: t.calc(a).mul(0.6).equal(),
          height: t.calc(a).mul(0.15).equal(),
          backgroundColor: "currentcolor",
          borderRadius: o,
          transition: [`background ${e} ${n}`, `transform ${e} ${n}`, `top ${e} ${n}`, `color ${e} ${n}`].join(","),
          content: '""'
        },
        "&::before": {
          transform: `rotate(45deg) translateY(${l(t.calc(i).mul(-1).equal())})`
        },
        "&::after": {
          transform: `rotate(-45deg) translateY(${l(i)})`
        }
      }
    }
  };
}, P = (t) => {
  const {
    antCls: r,
    componentCls: e,
    fontSize: n,
    motionDurationSlow: o,
    motionDurationMid: a,
    motionEaseInOut: i,
    paddingXS: d,
    padding: c,
    colorSplit: h,
    lineWidth: u,
    zIndexPopup: S,
    borderRadiusLG: g,
    subMenuItemBorderRadius: p,
    menuArrowSize: I,
    menuArrowOffset: s,
    lineType: f,
    menuPanelMaskInset: $,
    groupTitleLineHeight: v,
    groupTitleFontSize: b
  } = t;
  return [
    // Misc
    {
      "": {
        [`${e}`]: Object.assign(Object.assign({}, x()), {
          // Hidden
          "&-hidden": {
            display: "none"
          }
        })
      },
      [`${e}-submenu-hidden`]: {
        display: "none"
      }
    },
    {
      [e]: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, j(t)), x()), {
        marginBottom: 0,
        paddingInlineStart: 0,
        // Override default ul/ol
        fontSize: n,
        lineHeight: 0,
        listStyle: "none",
        outline: "none",
        // Magic cubic here but smooth transition
        transition: `width ${o} cubic-bezier(0.2, 0, 0, 1) 0s`,
        "ul, ol": {
          margin: 0,
          padding: 0,
          listStyle: "none"
        },
        // Overflow ellipsis
        "&-overflow": {
          display: "flex",
          [`${e}-item`]: {
            flex: "none"
          }
        },
        [`${e}-item, ${e}-submenu, ${e}-submenu-title`]: {
          borderRadius: t.itemBorderRadius
        },
        [`${e}-item-group-title`]: {
          padding: `${l(d)} ${l(c)}`,
          fontSize: b,
          lineHeight: v,
          transition: `all ${o}`
        },
        [`&-horizontal ${e}-submenu`]: {
          transition: [`border-color ${o} ${i}`, `background ${o} ${i}`].join(",")
        },
        [`${e}-submenu, ${e}-submenu-inline`]: {
          transition: [`border-color ${o} ${i}`, `background ${o} ${i}`, `padding ${a} ${i}`].join(",")
        },
        [`${e}-submenu ${e}-sub`]: {
          cursor: "initial",
          transition: [`background ${o} ${i}`, `padding ${o} ${i}`].join(",")
        },
        [`${e}-title-content`]: {
          transition: `color ${o}`,
          // https://github.com/ant-design/ant-design/issues/41143
          [`> ${r}-typography-ellipsis-single-line`]: {
            display: "inline",
            verticalAlign: "unset"
          }
        },
        [`${e}-item a`]: {
          "&::before": {
            position: "absolute",
            inset: 0,
            backgroundColor: "transparent",
            content: '""'
          }
        },
        // Removed a Badge related style seems it's safe
        // https://github.com/ant-design/ant-design/issues/19809
        // >>>>> Divider
        [`${e}-item-divider`]: {
          overflow: "hidden",
          lineHeight: 0,
          borderColor: h,
          borderStyle: f,
          borderWidth: 0,
          borderTopWidth: u,
          marginBlock: u,
          padding: 0,
          "&-dashed": {
            borderStyle: "dashed"
          }
        }
      }), M(t)), {
        [`${e}-item-group`]: {
          [`${e}-item-group-list`]: {
            margin: 0,
            padding: 0,
            [`${e}-item, ${e}-submenu-title`]: {
              paddingInline: `${l(t.calc(n).mul(2).equal())} ${l(c)}`
            }
          }
        },
        // ======================= Sub Menu =======================
        "&-submenu": {
          "&-popup": {
            position: "absolute",
            zIndex: S,
            borderRadius: g,
            boxShadow: "none",
            transformOrigin: "0 0",
            [`&${e}-submenu`]: {
              background: "transparent"
            },
            // https://github.com/ant-design/ant-design/issues/13955
            "&::before": {
              position: "absolute",
              inset: `${l($)} 0 0`,
              zIndex: -1,
              width: "100%",
              height: "100%",
              opacity: 0,
              content: '""'
            }
          },
          // https://github.com/ant-design/ant-design/issues/13955
          "&-placement-rightTop::before": {
            top: 0,
            insetInlineStart: $
          },
          "\n          &-placement-leftTop,\n          &-placement-bottomRight,\n          ": {
            transformOrigin: "100% 0"
          },
          "\n          &-placement-leftBottom,\n          &-placement-topRight,\n          ": {
            transformOrigin: "100% 100%"
          },
          "\n          &-placement-rightBottom,\n          &-placement-topLeft,\n          ": {
            transformOrigin: "0 100%"
          },
          "\n          &-placement-bottomLeft,\n          &-placement-rightTop,\n          ": {
            transformOrigin: "0 0"
          },
          "\n          &-placement-leftTop,\n          &-placement-leftBottom\n          ": {
            paddingInlineEnd: t.paddingXS
          },
          "\n          &-placement-rightTop,\n          &-placement-rightBottom\n          ": {
            paddingInlineStart: t.paddingXS
          },
          "\n          &-placement-topRight,\n          &-placement-topLeft\n          ": {
            paddingBottom: t.paddingXS
          },
          "\n          &-placement-bottomRight,\n          &-placement-bottomLeft\n          ": {
            paddingTop: t.paddingXS
          },
          [`> ${e}`]: Object.assign(Object.assign(Object.assign({
            borderRadius: g
          }, M(t)), O(t)), {
            [`${e}-item, ${e}-submenu > ${e}-submenu-title`]: {
              borderRadius: p
            },
            [`${e}-submenu-title::after`]: {
              transition: `transform ${o} ${i}`
            }
          })
        }
      }), O(t)), {
        [`&-inline-collapsed ${e}-submenu-arrow,
        &-inline ${e}-submenu-arrow`]: {
          // ↓
          "&::before": {
            transform: `rotate(-45deg) translateX(${l(s)})`
          },
          "&::after": {
            transform: `rotate(45deg) translateX(${l(t.calc(s).mul(-1).equal())})`
          }
        },
        [`${e}-submenu-open${e}-submenu-inline > ${e}-submenu-title > ${e}-submenu-arrow`]: {
          // ↑
          transform: `translateY(${l(t.calc(I).mul(0.2).mul(-1).equal())})`,
          "&::after": {
            transform: `rotate(-45deg) translateX(${l(t.calc(s).mul(-1).equal())})`
          },
          "&::before": {
            transform: `rotate(45deg) translateX(${l(s)})`
          }
        }
      })
    },
    // Integration with header element so menu items have the same height
    {
      [`${r}-layout-header`]: {
        [e]: {
          lineHeight: "inherit"
        }
      }
    }
  ];
}, F = (t) => {
  const {
    colorPrimary: r,
    colorError: e,
    colorTextDisabled: n,
    colorErrorBg: o,
    colorText: a,
    colorTextDescription: i,
    colorBgContainer: d,
    colorFillAlter: c,
    colorFillContent: h,
    lineWidth: u,
    lineWidthBold: S,
    controlItemBgActive: g,
    colorBgTextHover: p,
    controlHeightLG: I,
    lineHeight: s,
    colorBgElevated: f,
    marginXXS: $,
    padding: v,
    fontSize: b,
    controlHeightSM: H,
    fontSizeLG: T,
    colorTextLightSolid: B,
    colorErrorHover: z
  } = t, C = new A(B).setAlpha(0.65).toRgbString();
  return {
    dropdownWidth: 160,
    zIndexPopup: t.zIndexPopupBase + 50,
    radiusItem: t.borderRadiusLG,
    itemBorderRadius: t.borderRadiusLG,
    radiusSubMenuItem: t.borderRadiusSM,
    subMenuItemBorderRadius: t.borderRadiusSM,
    colorItemText: a,
    itemColor: a,
    colorItemTextHover: a,
    itemHoverColor: a,
    colorItemTextHoverHorizontal: r,
    horizontalItemHoverColor: r,
    colorGroupTitle: i,
    groupTitleColor: i,
    colorItemTextSelected: r,
    itemSelectedColor: r,
    colorItemTextSelectedHorizontal: r,
    horizontalItemSelectedColor: r,
    colorItemBg: d,
    itemBg: d,
    colorItemBgHover: p,
    itemHoverBg: p,
    colorItemBgActive: h,
    itemActiveBg: g,
    colorSubItemBg: c,
    subMenuItemBg: c,
    colorItemBgSelected: g,
    itemSelectedBg: g,
    colorItemBgSelectedHorizontal: "transparent",
    horizontalItemSelectedBg: "transparent",
    colorActiveBarWidth: 0,
    activeBarWidth: 0,
    colorActiveBarHeight: S,
    activeBarHeight: S,
    colorActiveBarBorderSize: u,
    activeBarBorderWidth: u,
    // Disabled
    colorItemTextDisabled: n,
    itemDisabledColor: n,
    // Danger
    colorDangerItemText: e,
    dangerItemColor: e,
    colorDangerItemTextHover: e,
    dangerItemHoverColor: e,
    colorDangerItemTextSelected: e,
    dangerItemSelectedColor: e,
    colorDangerItemBgActive: o,
    dangerItemActiveBg: o,
    colorDangerItemBgSelected: o,
    dangerItemSelectedBg: o,
    itemMarginInline: t.marginXXS,
    horizontalItemBorderRadius: 0,
    horizontalItemHoverBg: "transparent",
    itemHeight: I,
    groupTitleLineHeight: s,
    collapsedWidth: I * 2,
    popupBg: f,
    itemMarginBlock: $,
    itemPaddingInline: v,
    horizontalLineHeight: `${I * 1.15}px`,
    iconSize: b,
    iconMarginInlineEnd: H - b,
    collapsedIconSize: T,
    groupTitleFontSize: b,
    // Disabled
    darkItemDisabledColor: new A(B).setAlpha(0.25).toRgbString(),
    // Dark
    darkItemColor: C,
    darkDangerItemColor: e,
    darkItemBg: "#001529",
    darkPopupBg: "#001529",
    darkSubMenuItemBg: "#000c17",
    darkItemSelectedColor: B,
    darkItemSelectedBg: r,
    darkDangerItemSelectedBg: e,
    darkItemHoverBg: "transparent",
    darkGroupTitleColor: C,
    darkItemHoverColor: B,
    darkDangerItemHoverColor: z,
    darkDangerItemSelectedColor: B,
    darkDangerItemActiveBg: e,
    // internal
    itemWidth: ""
  };
}, Y = (t) => Object.assign(Object.assign({}, t), {
  itemWidth: t.activeBarWidth ? `calc(100% + ${t.activeBarBorderWidth}px)` : `calc(100% - ${t.itemMarginInline * 2}px)`
}), Ie = function(t) {
  let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : t, e = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !0;
  return E("Menu", (o) => {
    const {
      colorBgElevated: a,
      colorPrimary: i,
      colorTextLightSolid: d,
      controlHeightLG: c,
      fontSize: h,
      darkItemColor: u,
      darkDangerItemColor: S,
      darkItemBg: g,
      darkSubMenuItemBg: p,
      darkItemSelectedColor: I,
      darkItemSelectedBg: s,
      darkDangerItemSelectedBg: f,
      darkItemHoverBg: $,
      darkGroupTitleColor: v,
      darkItemHoverColor: b,
      darkItemDisabledColor: H,
      darkDangerItemHoverColor: T,
      darkDangerItemSelectedColor: B,
      darkDangerItemActiveBg: z
    } = o, C = o.calc(h).div(7).mul(5).equal(), m = y(o, {
      menuArrowSize: C,
      menuHorizontalHeight: o.calc(c).mul(1.15).equal(),
      menuArrowOffset: o.calc(C).mul(0.25).equal(),
      menuPanelMaskInset: -7,
      // Still a hardcode here since it's offset by rc-align
      menuSubMenuBg: a,
      calc: o.calc
    }), R = y(m, {
      itemColor: u,
      itemHoverColor: b,
      groupTitleColor: v,
      itemSelectedColor: I,
      itemBg: g,
      popupBg: g,
      subMenuItemBg: p,
      itemActiveBg: "transparent",
      itemSelectedBg: s,
      activeBarHeight: 0,
      activeBarBorderWidth: 0,
      itemHoverBg: $,
      // Disabled
      itemDisabledColor: H,
      // Danger
      dangerItemColor: S,
      dangerItemHoverColor: T,
      dangerItemSelectedColor: B,
      dangerItemActiveBg: z,
      dangerItemSelectedBg: f,
      menuSubMenuBg: p,
      // Horizontal
      horizontalItemSelectedColor: d,
      horizontalItemSelectedBg: i
    });
    return [
      // Basic
      P(m),
      // Horizontal
      X(m),
      // Hard code for some light style
      // Vertical
      G(m),
      // Hard code for some light style
      // Theme
      w(m, "light"),
      w(R, "dark"),
      // RTL
      q(m),
      // Motion
      L(m),
      D(m, "slide-up"),
      D(m, "slide-down"),
      W(m, "zoom-big")
    ];
  }, F, {
    deprecatedTokens: [["colorGroupTitle", "groupTitleColor"], ["radiusItem", "itemBorderRadius"], ["radiusSubMenuItem", "subMenuItemBorderRadius"], ["colorItemText", "itemColor"], ["colorItemTextHover", "itemHoverColor"], ["colorItemTextHoverHorizontal", "horizontalItemHoverColor"], ["colorItemTextSelected", "itemSelectedColor"], ["colorItemTextSelectedHorizontal", "horizontalItemSelectedColor"], ["colorItemTextDisabled", "itemDisabledColor"], ["colorDangerItemText", "dangerItemColor"], ["colorDangerItemTextHover", "dangerItemHoverColor"], ["colorDangerItemTextSelected", "dangerItemSelectedColor"], ["colorDangerItemBgActive", "dangerItemActiveBg"], ["colorDangerItemBgSelected", "dangerItemSelectedBg"], ["colorItemBg", "itemBg"], ["colorItemBgHover", "itemHoverBg"], ["colorSubItemBg", "subMenuItemBg"], ["colorItemBgActive", "itemActiveBg"], ["colorItemBgSelectedHorizontal", "horizontalItemSelectedBg"], ["colorActiveBarWidth", "activeBarWidth"], ["colorActiveBarHeight", "activeBarHeight"], ["colorActiveBarBorderSize", "activeBarBorderWidth"], ["colorItemBgSelected", "itemSelectedBg"]],
    format: Y,
    // Dropdown will handle menu style self. We do not need to handle this.
    injectStyle: e,
    unitless: {
      groupTitleLineHeight: !0
    }
  })(t, r);
};
export {
  Ie as default,
  Y as formatComponentToken,
  F as prepareComponentToken
};
