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 m } 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 { resetComponent as C, textEllipsis as g, resetIcon as I } from "../../style/index.mjs";
import { genCompactItemStyle as y } from "../../style/compact-item.mjs";
import { genStyleHooks as v } from "../../theme/util/genComponentStyleHook.mjs";
import { merge as l } from "../../theme/util/statistic.mjs";
import H from "./dropdown.mjs";
import x from "./multiple.mjs";
import B from "./single.mjs";
const z = (o) => {
  const {
    componentCls: e,
    selectorBg: t
  } = o;
  return {
    position: "relative",
    backgroundColor: t,
    border: `${m(o.lineWidth)} ${o.lineType} ${o.colorBorder}`,
    transition: `all ${o.motionDurationMid} ${o.motionEaseInOut}`,
    input: {
      cursor: "pointer"
    },
    [`${e}-show-search&`]: {
      cursor: "text",
      input: {
        cursor: "auto",
        color: "inherit",
        height: "100%"
      }
    },
    [`${e}-disabled&`]: {
      color: o.colorTextDisabled,
      background: o.colorBgContainerDisabled,
      cursor: "not-allowed",
      [`${e}-multiple&`]: {
        background: o.multipleSelectorBgDisabled
      },
      input: {
        cursor: "not-allowed"
      }
    }
  };
}, d = function(o, e) {
  let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
  const {
    componentCls: r,
    borderHoverColor: i,
    antCls: a,
    borderActiveColor: n,
    outlineColor: c,
    controlOutlineWidth: s
  } = e, p = t ? {
    [`${r}-selector`]: {
      borderColor: n
    }
  } : {};
  return {
    [o]: {
      [`&:not(${r}-disabled):not(${r}-customize-input):not(${a}-pagination-size-changer)`]: Object.assign(Object.assign({}, p), {
        [`&:hover ${r}-selector`]: {
          borderColor: i
        },
        [`${r}-focused& ${r}-selector`]: {
          borderColor: n,
          boxShadow: `0 0 0 ${m(s)} ${c}`,
          outline: 0
        }
      })
    }
  };
}, w = (o) => {
  const {
    componentCls: e
  } = o;
  return {
    [`${e}-selection-search-input`]: {
      margin: 0,
      padding: 0,
      background: "transparent",
      border: "none",
      outline: "none",
      appearance: "none",
      fontFamily: "inherit",
      "&::-webkit-search-cancel-button": {
        display: "none",
        "-webkit-appearance": "none"
      }
    }
  };
}, O = (o) => {
  const {
    antCls: e,
    componentCls: t,
    inputPaddingHorizontalBase: r,
    iconCls: i
  } = o;
  return {
    [t]: Object.assign(Object.assign({}, C(o)), {
      position: "relative",
      display: "inline-block",
      cursor: "pointer",
      [`&:not(${t}-customize-input) ${t}-selector`]: Object.assign(Object.assign({}, z(o)), w(o)),
      // [`&:not(&-disabled):hover ${selectCls}-selector`]: {
      //   ...genHoverStyle(token),
      // },
      // ======================== Selection ========================
      [`${t}-selection-item`]: Object.assign(Object.assign({
        flex: 1,
        fontWeight: "normal",
        position: "relative",
        userSelect: "none"
      }, g), {
        // https://github.com/ant-design/ant-design/issues/40421
        [`> ${e}-typography`]: {
          display: "inline"
        }
      }),
      // ======================= Placeholder =======================
      [`${t}-selection-placeholder`]: Object.assign(Object.assign({}, g), {
        flex: 1,
        color: o.colorTextPlaceholder,
        pointerEvents: "none"
      }),
      // ========================== Arrow ==========================
      [`${t}-arrow`]: Object.assign(Object.assign({}, I()), {
        position: "absolute",
        top: "50%",
        insetInlineStart: "auto",
        insetInlineEnd: r,
        height: o.fontSizeIcon,
        marginTop: o.calc(o.fontSizeIcon).mul(-1).div(2).equal(),
        color: o.colorTextQuaternary,
        fontSize: o.fontSizeIcon,
        lineHeight: 1,
        textAlign: "center",
        pointerEvents: "none",
        display: "flex",
        alignItems: "center",
        [i]: {
          verticalAlign: "top",
          transition: `transform ${o.motionDurationSlow}`,
          "> svg": {
            verticalAlign: "top"
          },
          [`&:not(${t}-suffix)`]: {
            pointerEvents: "auto"
          }
        },
        [`${t}-disabled &`]: {
          cursor: "not-allowed"
        },
        "> *:not(:last-child)": {
          marginInlineEnd: 8
          // FIXME: magic
        }
      }),
      // ========================== Clear ==========================
      [`${t}-clear`]: {
        position: "absolute",
        top: "50%",
        insetInlineStart: "auto",
        insetInlineEnd: r,
        zIndex: 1,
        display: "inline-block",
        width: o.fontSizeIcon,
        height: o.fontSizeIcon,
        marginTop: o.calc(o.fontSizeIcon).mul(-1).div(2).equal(),
        color: o.colorTextQuaternary,
        fontSize: o.fontSizeIcon,
        fontStyle: "normal",
        lineHeight: 1,
        textAlign: "center",
        textTransform: "none",
        background: o.clearBg,
        cursor: "pointer",
        opacity: 0,
        transition: `color ${o.motionDurationMid} ease, opacity ${o.motionDurationSlow} ease`,
        textRendering: "auto",
        "&:before": {
          display: "block"
        },
        "&:hover": {
          color: o.colorTextTertiary
        }
      },
      "&:hover": {
        [`${t}-clear`]: {
          opacity: 1
        }
      }
    }),
    // ========================= Feedback ==========================
    [`${t}-has-feedback`]: {
      [`${t}-clear`]: {
        insetInlineEnd: o.calc(r).add(o.fontSize).add(o.paddingXS).equal()
      }
    }
  };
}, E = (o) => {
  const {
    componentCls: e
  } = o;
  return [
    {
      [e]: {
        // ==================== BorderLess ====================
        [`&-borderless ${e}-selector`]: {
          backgroundColor: "transparent !important",
          borderColor: "transparent !important",
          boxShadow: "none !important"
        },
        // ==================== In Form ====================
        [`&${e}-in-form-item`]: {
          width: "100%"
        }
      }
    },
    // =====================================================
    // ==                       LTR                       ==
    // =====================================================
    // Base
    O(o),
    // Single
    B(o),
    // Multiple
    x(o),
    // Dropdown
    H(o),
    // =====================================================
    // ==                       RTL                       ==
    // =====================================================
    {
      [`${e}-rtl`]: {
        direction: "rtl"
      }
    },
    // =====================================================
    // ==                     Status                      ==
    // =====================================================
    d(e, l(o, {
      borderHoverColor: o.colorPrimaryHover,
      borderActiveColor: o.colorPrimary,
      outlineColor: o.controlOutline
    })),
    d(`${e}-status-error`, l(o, {
      borderHoverColor: o.colorErrorHover,
      borderActiveColor: o.colorError,
      outlineColor: o.colorErrorOutline
    }), !0),
    d(`${e}-status-warning`, l(o, {
      borderHoverColor: o.colorWarningHover,
      borderActiveColor: o.colorWarning,
      outlineColor: o.colorWarningOutline
    }), !0),
    // =====================================================
    // ==             Space Compact                       ==
    // =====================================================
    y(o, {
      borderElCls: `${e}-selector`,
      focusElCls: `${e}-focused`
    })
  ];
}, D = (o) => {
  const {
    fontSize: e,
    lineHeight: t,
    controlHeight: r,
    controlPaddingHorizontal: i,
    zIndexPopupBase: a,
    colorText: n,
    fontWeightStrong: c,
    controlItemBgActive: s,
    controlItemBgHover: p,
    colorBgContainer: u,
    colorFillSecondary: b,
    controlHeightLG: h,
    controlHeightSM: S,
    colorBgContainerDisabled: f,
    colorTextDisabled: $
  } = o;
  return {
    zIndexPopup: a + 50,
    optionSelectedColor: n,
    optionSelectedFontWeight: c,
    optionSelectedBg: s,
    optionActiveBg: p,
    optionPadding: `${(r - e * t) / 2}px ${i}px`,
    optionFontSize: e,
    optionLineHeight: t,
    optionHeight: r,
    selectorBg: u,
    clearBg: u,
    singleItemHeightLG: h,
    multipleItemBg: b,
    multipleItemBorderColor: "transparent",
    multipleItemHeight: S,
    multipleItemHeightLG: r,
    multipleSelectorBgDisabled: f,
    multipleItemColorDisabled: $,
    multipleItemBorderColorDisabled: "transparent",
    showArrowPaddingInlineEnd: Math.ceil(o.fontSize * 1.25)
  };
}, Z = v("Select", (o, e) => {
  let {
    rootPrefixCls: t
  } = e;
  const r = l(o, {
    rootPrefixCls: t,
    inputPaddingHorizontalBase: o.calc(o.paddingSM).sub(1).equal(),
    multipleSelectItemHeight: o.multipleItemHeight,
    selectHeight: o.controlHeight
  });
  return [E(r)];
}, D, {
  unitless: {
    optionLineHeight: !0,
    optionSelectedFontWeight: !0
  }
});
export {
  Z as default,
  D as prepareComponentToken
};
