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 g } 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 m, genFocusStyle as u } from "../../style/index.mjs";
import { genStyleHooks as $ } from "../../theme/util/genComponentStyleHook.mjs";
import { merge as S } from "../../theme/util/statistic.mjs";
import { TinyColor as p } from "../../../../@ctrl/tinycolor/dist/module/index.mjs";
const I = (n) => {
  const {
    componentCls: i,
    trackHeightSM: c,
    trackPadding: r,
    trackMinWidthSM: s,
    innerMinMarginSM: l,
    innerMaxMarginSM: o,
    handleSizeSM: e,
    calc: t
  } = n, a = `${i}-inner`, d = g(t(e).add(t(r).mul(2)).equal()), h = g(t(o).mul(2).equal());
  return {
    [i]: {
      [`&${i}-small`]: {
        minWidth: s,
        height: c,
        lineHeight: g(c),
        [`${i}-inner`]: {
          paddingInlineStart: o,
          paddingInlineEnd: l,
          [`${a}-checked`]: {
            marginInlineStart: `calc(-100% + ${d} - ${h})`,
            marginInlineEnd: `calc(100% - ${d} + ${h})`
          },
          [`${a}-unchecked`]: {
            marginTop: t(c).mul(-1).equal(),
            marginInlineStart: 0,
            marginInlineEnd: 0
          }
        },
        [`${i}-handle`]: {
          width: e,
          height: e
        },
        [`${i}-loading-icon`]: {
          top: t(t(e).sub(n.switchLoadingIconSize)).div(2).equal(),
          fontSize: n.switchLoadingIconSize
        },
        [`&${i}-checked`]: {
          [`${i}-inner`]: {
            paddingInlineStart: l,
            paddingInlineEnd: o,
            [`${a}-checked`]: {
              marginInlineStart: 0,
              marginInlineEnd: 0
            },
            [`${a}-unchecked`]: {
              marginInlineStart: `calc(100% - ${d} + ${h})`,
              marginInlineEnd: `calc(-100% + ${d} - ${h})`
            }
          },
          [`${i}-handle`]: {
            insetInlineStart: `calc(100% - ${g(t(e).add(r).equal())})`
          }
        },
        [`&:not(${i}-disabled):active`]: {
          [`&:not(${i}-checked) ${a}`]: {
            [`${a}-unchecked`]: {
              marginInlineStart: t(n.marginXXS).div(2).equal(),
              marginInlineEnd: t(n.marginXXS).mul(-1).div(2).equal()
            }
          },
          [`&${i}-checked ${a}`]: {
            [`${a}-checked`]: {
              marginInlineStart: t(n.marginXXS).mul(-1).div(2).equal(),
              marginInlineEnd: t(n.marginXXS).div(2).equal()
            }
          }
        }
      }
    }
  };
}, b = (n) => {
  const {
    componentCls: i,
    handleSize: c,
    calc: r
  } = n;
  return {
    [i]: {
      [`${i}-loading-icon${n.iconCls}`]: {
        position: "relative",
        top: r(r(c).sub(n.fontSize)).div(2).equal(),
        color: n.switchLoadingIconColor,
        verticalAlign: "top"
      },
      [`&${i}-checked ${i}-loading-icon`]: {
        color: n.switchColor
      }
    }
  };
}, w = (n) => {
  const {
    componentCls: i,
    trackPadding: c,
    handleBg: r,
    handleShadow: s,
    handleSize: l,
    calc: o
  } = n, e = `${i}-handle`;
  return {
    [i]: {
      [e]: {
        position: "absolute",
        top: c,
        insetInlineStart: c,
        width: l,
        height: l,
        transition: `all ${n.switchDuration} ease-in-out`,
        "&::before": {
          position: "absolute",
          top: 0,
          insetInlineEnd: 0,
          bottom: 0,
          insetInlineStart: 0,
          backgroundColor: r,
          borderRadius: o(l).div(2).equal(),
          boxShadow: s,
          transition: `all ${n.switchDuration} ease-in-out`,
          content: '""'
        }
      },
      [`&${i}-checked ${e}`]: {
        insetInlineStart: `calc(100% - ${g(o(l).add(c).equal())})`
      },
      [`&:not(${i}-disabled):active`]: {
        [`${e}::before`]: {
          insetInlineEnd: n.switchHandleActiveInset,
          insetInlineStart: 0
        },
        [`&${i}-checked ${e}::before`]: {
          insetInlineEnd: 0,
          insetInlineStart: n.switchHandleActiveInset
        }
      }
    }
  };
}, M = (n) => {
  const {
    componentCls: i,
    trackHeight: c,
    trackPadding: r,
    innerMinMargin: s,
    innerMaxMargin: l,
    handleSize: o,
    calc: e
  } = n, t = `${i}-inner`, a = g(e(o).add(e(r).mul(2)).equal()), d = g(e(l).mul(2).equal());
  return {
    [i]: {
      [t]: {
        display: "block",
        overflow: "hidden",
        borderRadius: 100,
        height: "100%",
        paddingInlineStart: l,
        paddingInlineEnd: s,
        transition: `padding-inline-start ${n.switchDuration} ease-in-out, padding-inline-end ${n.switchDuration} ease-in-out`,
        [`${t}-checked, ${t}-unchecked`]: {
          display: "block",
          color: n.colorTextLightSolid,
          fontSize: n.fontSizeSM,
          transition: `margin-inline-start ${n.switchDuration} ease-in-out, margin-inline-end ${n.switchDuration} ease-in-out`,
          pointerEvents: "none"
        },
        [`${t}-checked`]: {
          marginInlineStart: `calc(-100% + ${a} - ${d})`,
          marginInlineEnd: `calc(100% - ${a} + ${d})`
        },
        [`${t}-unchecked`]: {
          marginTop: e(c).mul(-1).equal(),
          marginInlineStart: 0,
          marginInlineEnd: 0
        }
      },
      [`&${i}-checked ${t}`]: {
        paddingInlineStart: s,
        paddingInlineEnd: l,
        [`${t}-checked`]: {
          marginInlineStart: 0,
          marginInlineEnd: 0
        },
        [`${t}-unchecked`]: {
          marginInlineStart: `calc(100% - ${a} + ${d})`,
          marginInlineEnd: `calc(-100% + ${a} - ${d})`
        }
      },
      [`&:not(${i}-disabled):active`]: {
        [`&:not(${i}-checked) ${t}`]: {
          [`${t}-unchecked`]: {
            marginInlineStart: e(r).mul(2).equal(),
            marginInlineEnd: e(r).mul(-1).mul(2).equal()
          }
        },
        [`&${i}-checked ${t}`]: {
          [`${t}-checked`]: {
            marginInlineStart: e(r).mul(-1).mul(2).equal(),
            marginInlineEnd: e(r).mul(2).equal()
          }
        }
      }
    }
  };
}, v = (n) => {
  const {
    componentCls: i,
    trackHeight: c,
    trackMinWidth: r
  } = n;
  return {
    [i]: Object.assign(Object.assign(Object.assign(Object.assign({}, m(n)), {
      position: "relative",
      display: "inline-block",
      boxSizing: "border-box",
      minWidth: r,
      height: c,
      lineHeight: `${g(c)}`,
      verticalAlign: "middle",
      background: n.colorTextQuaternary,
      border: "0",
      borderRadius: 100,
      cursor: "pointer",
      transition: `all ${n.motionDurationMid}`,
      userSelect: "none",
      [`&:hover:not(${i}-disabled)`]: {
        background: n.colorTextTertiary
      }
    }), u(n)), {
      [`&${i}-checked`]: {
        background: n.switchColor,
        [`&:hover:not(${i}-disabled)`]: {
          background: n.colorPrimaryHover
        }
      },
      [`&${i}-loading, &${i}-disabled`]: {
        cursor: "not-allowed",
        opacity: n.switchDisabledOpacity,
        "*": {
          boxShadow: "none",
          cursor: "not-allowed"
        }
      },
      // rtl style
      [`&${i}-rtl`]: {
        direction: "rtl"
      }
    })
  };
}, C = (n) => {
  const {
    fontSize: i,
    lineHeight: c,
    controlHeight: r,
    colorWhite: s
  } = n, l = i * c, o = r / 2, e = 2, t = l - e * 2, a = o - e * 2;
  return {
    trackHeight: l,
    trackHeightSM: o,
    trackMinWidth: t * 2 + e * 4,
    trackMinWidthSM: a * 2 + e * 2,
    trackPadding: e,
    // Fixed value
    handleBg: s,
    handleSize: t,
    handleSizeSM: a,
    handleShadow: `0 2px 4px 0 ${new p("#00230b").setAlpha(0.2).toRgbString()}`,
    innerMinMargin: t / 2,
    innerMaxMargin: t + e + e * 2,
    innerMinMarginSM: a / 2,
    innerMaxMarginSM: a + e + e * 2
  };
}, j = $("Switch", (n) => {
  const i = S(n, {
    switchDuration: n.motionDurationMid,
    switchColor: n.colorPrimary,
    switchDisabledOpacity: n.opacityLoading,
    switchLoadingIconSize: n.calc(n.fontSizeIcon).mul(0.75).equal(),
    switchLoadingIconColor: `rgba(0, 0, 0, ${n.opacityLoading})`,
    switchHandleActiveInset: "-30%"
  });
  return [
    v(i),
    // inner style
    M(i),
    // handle style
    w(i),
    // loading style
    b(i),
    // small style
    I(i)
  ];
}, C);
export {
  j as default,
  C as prepareComponentToken
};
