import { initInputToken as C, genBasicInputStyle as $, genStatusStyle as f, genInputGroupStyle as z, genDisabledStyle as A, genPlaceholderStyle as W, initComponentToken as T } from "../../input/style/index.mjs";
import { resetComponent as c, resetIcon as G } from "../../style/index.mjs";
import { genCompactItemStyle as H } from "../../style/compact-item.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 o } 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 M } from "../../theme/util/genComponentStyleHook.mjs";
import { merge as L } from "../../theme/util/statistic.mjs";
const m = (e, n) => {
  let {
    componentCls: i,
    borderRadiusSM: t,
    borderRadiusLG: a
  } = e;
  const r = n === "lg" ? a : t;
  return {
    [`&-${n}`]: {
      [`${i}-handler-wrap`]: {
        borderStartEndRadius: r,
        borderEndEndRadius: r
      },
      [`${i}-handler-up`]: {
        borderStartEndRadius: r
      },
      [`${i}-handler-down`]: {
        borderEndEndRadius: r
      }
    }
  };
}, D = (e) => {
  const {
    componentCls: n,
    lineWidth: i,
    lineType: t,
    colorBorder: a,
    borderRadius: r,
    fontSizeLG: s,
    controlHeightLG: p,
    controlHeightSM: S,
    colorError: w,
    paddingInlineSM: y,
    colorTextDescription: u,
    motionDurationMid: d,
    handleHoverColor: x,
    paddingInline: R,
    paddingBlock: O,
    handleBg: j,
    handleActiveBg: I,
    colorTextDisabled: E,
    borderRadiusSM: b,
    borderRadiusLG: g,
    controlWidth: v,
    handleOpacity: B,
    handleBorderColor: h,
    calc: l
  } = e;
  return [
    {
      [n]: Object.assign(Object.assign(Object.assign(Object.assign({}, c(e)), $(e)), f(e, n)), {
        display: "inline-block",
        width: v,
        margin: 0,
        padding: 0,
        border: `${o(i)} ${t} ${a}`,
        borderRadius: r,
        "&-rtl": {
          direction: "rtl",
          [`${n}-input`]: {
            direction: "rtl"
          }
        },
        "&-lg": {
          padding: 0,
          fontSize: s,
          borderRadius: g,
          [`input${n}-input`]: {
            height: l(p).sub(l(i).mul(2)).equal()
          }
        },
        "&-sm": {
          padding: 0,
          borderRadius: b,
          [`input${n}-input`]: {
            height: l(S).sub(l(i).mul(2)).equal(),
            padding: `0 ${o(y)}`
          }
        },
        // ===================== Out Of Range =====================
        "&-out-of-range": {
          [`${n}-input-wrap`]: {
            input: {
              color: w
            }
          }
        },
        // Style for input-group: input with label, with button or dropdown...
        "&-group": Object.assign(Object.assign(Object.assign({}, c(e)), z(e)), {
          "&-wrapper": {
            display: "inline-block",
            textAlign: "start",
            verticalAlign: "top",
            // https://github.com/ant-design/ant-design/issues/6403
            [`${n}-affix-wrapper`]: {
              width: "100%"
            },
            // Size
            "&-lg": {
              [`${n}-group-addon`]: {
                borderRadius: g,
                fontSize: e.fontSizeLG
              }
            },
            "&-sm": {
              [`${n}-group-addon`]: {
                borderRadius: b
              }
            },
            [`${n}-wrapper-disabled > ${n}-group-addon`]: Object.assign({}, A(e)),
            // Fix the issue of using icons in Space Compact mode
            // https://github.com/ant-design/ant-design/issues/45764
            [`&:not(${n}-compact-first-item):not(${n}-compact-last-item)${n}-compact-item`]: {
              [`${n}, ${n}-group-addon`]: {
                borderRadius: 0
              }
            },
            [`&:not(${n}-compact-last-item)${n}-compact-first-item`]: {
              [`${n}, ${n}-group-addon`]: {
                borderStartEndRadius: 0,
                borderEndEndRadius: 0
              }
            },
            [`&:not(${n}-compact-first-item)${n}-compact-last-item`]: {
              [`${n}, ${n}-group-addon`]: {
                borderStartStartRadius: 0,
                borderEndStartRadius: 0
              }
            }
          }
        }),
        [`&-disabled ${n}-input`]: {
          cursor: "not-allowed"
        },
        [n]: {
          "&-input": Object.assign(Object.assign(Object.assign(Object.assign({}, c(e)), {
            width: "100%",
            padding: `${o(O)} ${o(R)}`,
            textAlign: "start",
            backgroundColor: "transparent",
            border: 0,
            borderRadius: r,
            outline: 0,
            transition: `all ${d} linear`,
            appearance: "textfield",
            fontSize: "inherit"
          }), W(e.colorTextPlaceholder)), {
            '&[type="number"]::-webkit-inner-spin-button, &[type="number"]::-webkit-outer-spin-button': {
              margin: 0,
              /* stylelint-disable-next-line property-no-vendor-prefix */
              webkitAppearance: "none",
              appearance: "none"
            }
          })
        }
      })
    },
    // Handler
    {
      [n]: Object.assign(Object.assign(Object.assign({
        [`&:hover ${n}-handler-wrap, &-focused ${n}-handler-wrap`]: {
          opacity: 1
        },
        [`${n}-handler-wrap`]: {
          position: "absolute",
          insetBlockStart: 0,
          insetInlineEnd: 0,
          width: e.handleWidth,
          height: "100%",
          background: j,
          borderStartStartRadius: 0,
          borderStartEndRadius: r,
          borderEndEndRadius: r,
          borderEndStartRadius: 0,
          opacity: B,
          display: "flex",
          flexDirection: "column",
          alignItems: "stretch",
          transition: `opacity ${d} linear ${d}`,
          // Fix input number inside Menu makes icon too large
          // We arise the selector priority by nest selector here
          // https://github.com/ant-design/ant-design/issues/14367
          [`${n}-handler`]: {
            display: "flex",
            alignItems: "center",
            justifyContent: "center",
            flex: "auto",
            height: "40%",
            [`
              ${n}-handler-up-inner,
              ${n}-handler-down-inner
            `]: {
              marginInlineEnd: 0,
              fontSize: e.handleFontSize
            }
          }
        },
        [`${n}-handler`]: {
          height: "50%",
          overflow: "hidden",
          color: u,
          fontWeight: "bold",
          lineHeight: 0,
          textAlign: "center",
          cursor: "pointer",
          borderInlineStart: `${o(i)} ${t} ${h}`,
          transition: `all ${d} linear`,
          "&:active": {
            background: I
          },
          // Hover
          "&:hover": {
            height: "60%",
            [`
              ${n}-handler-up-inner,
              ${n}-handler-down-inner
            `]: {
              color: x
            }
          },
          "&-up-inner, &-down-inner": Object.assign(Object.assign({}, G()), {
            color: u,
            transition: `all ${d} linear`,
            userSelect: "none"
          })
        },
        [`${n}-handler-up`]: {
          borderStartEndRadius: r
        },
        [`${n}-handler-down`]: {
          borderBlockStart: `${o(i)} ${t} ${h}`,
          borderEndEndRadius: r
        }
      }, m(e, "lg")), m(e, "sm")), {
        // Disabled
        "&-disabled, &-readonly": {
          [`${n}-handler-wrap`]: {
            display: "none"
          },
          [`${n}-input`]: {
            color: "inherit"
          }
        },
        [`
          ${n}-handler-up-disabled,
          ${n}-handler-down-disabled
        `]: {
          cursor: "not-allowed"
        },
        [`
          ${n}-handler-up-disabled:hover &-handler-up-inner,
          ${n}-handler-down-disabled:hover &-handler-down-inner
        `]: {
          color: E
        }
      })
    },
    // Border-less
    {
      [`${n}-borderless`]: {
        borderColor: "transparent",
        boxShadow: "none",
        [`${n}-handler-down`]: {
          borderBlockStartWidth: 0
        }
      }
    }
  ];
}, P = (e) => {
  const {
    componentCls: n,
    paddingBlock: i,
    paddingInline: t,
    inputAffixPadding: a,
    controlWidth: r,
    borderRadiusLG: s,
    borderRadiusSM: p
  } = e;
  return {
    [`${n}-affix-wrapper`]: Object.assign(Object.assign(Object.assign({}, $(e)), f(e, `${n}-affix-wrapper`)), {
      // or number handler will cover form status
      position: "relative",
      display: "inline-flex",
      width: r,
      padding: 0,
      paddingInlineStart: t,
      "&-lg": {
        borderRadius: s
      },
      "&-sm": {
        borderRadius: p
      },
      [`&:not(${n}-affix-wrapper-disabled):hover`]: {
        zIndex: 1
      },
      "&-focused, &:focus": {
        zIndex: 1
      },
      [`&-disabled > ${n}-disabled`]: {
        background: "transparent"
      },
      [`> div${n}`]: {
        width: "100%",
        border: "none",
        outline: "none",
        [`&${n}-focused`]: {
          boxShadow: "none !important"
        }
      },
      [`input${n}-input`]: {
        padding: `${o(i)} 0`
      },
      "&::before": {
        display: "inline-block",
        width: 0,
        visibility: "hidden",
        content: '"\\a0"'
      },
      [`${n}-handler-wrap`]: {
        zIndex: 2
      },
      [n]: {
        "&-prefix, &-suffix": {
          display: "flex",
          flex: "none",
          alignItems: "center",
          pointerEvents: "none"
        },
        "&-prefix": {
          marginInlineEnd: a
        },
        "&-suffix": {
          position: "absolute",
          insetBlockStart: 0,
          insetInlineEnd: 0,
          zIndex: 1,
          height: "100%",
          marginInlineEnd: t,
          marginInlineStart: a
        }
      }
    })
  };
}, F = (e) => Object.assign(Object.assign({}, T(e)), {
  controlWidth: 90,
  handleWidth: e.controlHeightSM - e.lineWidth * 2,
  handleFontSize: e.fontSize / 2,
  handleVisible: "auto",
  handleActiveBg: e.colorFillAlter,
  handleBg: e.colorBgContainer,
  handleHoverColor: e.colorPrimary,
  handleBorderColor: e.colorBorder,
  handleOpacity: 0
}), N = (e) => Object.assign(Object.assign({}, e), {
  handleOpacity: e.handleVisible === !0 ? 1 : 0
}), dn = M("InputNumber", (e) => {
  const n = L(e, C(e));
  return [
    D(n),
    P(n),
    // =====================================================
    // ==             Space Compact                       ==
    // =====================================================
    H(n)
  ];
}, F, {
  format: N,
  unitless: {
    handleOpacity: !0
  }
});
export {
  dn as default,
  N as formatComponentToken,
  m as genRadiusStyle,
  F as prepareComponentToken
};
