import W from "../../../@babel/runtime/helpers/esm/extends.mjs";
import x from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import E from "../../../@babel/runtime/helpers/esm/defineProperty.mjs";
import A from "../../../@babel/runtime/helpers/esm/objectWithoutProperties.mjs";
import V from "../../../classnames/index.mjs";
import e from "../../../rc-util/es/KeyCode.mjs";
import * as g from "react";
import j from "../context.mjs";
import { getIndex as s, getDirectionStyle as B } from "../util.mjs";
var $ = ["prefixCls", "value", "valueIndex", "onStartMove", "style", "render", "dragging", "onOffsetChange", "onChangeComplete"], z = /* @__PURE__ */ g.forwardRef(function(r, _) {
  var i, m, y = r.prefixCls, d = r.value, l = r.valueIndex, H = r.onStartMove, I = r.style, h = r.render, C = r.dragging, P = r.onOffsetChange, v = r.onChangeComplete, p = A(r, $), a = g.useContext(j), f = a.min, N = a.max, t = a.direction, c = a.disabled, w = a.keyboard, F = a.range, O = a.tabIndex, S = a.ariaLabelForHandle, M = a.ariaLabelledByForHandle, K = a.ariaValueTextFormatterForHandle, T = a.styles, U = a.classNames, u = "".concat(y, "-handle"), k = function(o) {
    c || H(o, l);
  }, G = function(o) {
    if (!c && w) {
      var n = null;
      switch (o.which || o.keyCode) {
        case e.LEFT:
          n = t === "ltr" || t === "btt" ? -1 : 1;
          break;
        case e.RIGHT:
          n = t === "ltr" || t === "btt" ? 1 : -1;
          break;
        case e.UP:
          n = t !== "ttb" ? 1 : -1;
          break;
        case e.DOWN:
          n = t !== "ttb" ? -1 : 1;
          break;
        case e.HOME:
          n = "min";
          break;
        case e.END:
          n = "max";
          break;
        case e.PAGE_UP:
          n = 2;
          break;
        case e.PAGE_DOWN:
          n = -2;
          break;
      }
      n !== null && (o.preventDefault(), P(n, l));
    }
  }, L = function(o) {
    switch (o.which || o.keyCode) {
      case e.LEFT:
      case e.RIGHT:
      case e.UP:
      case e.DOWN:
      case e.HOME:
      case e.END:
      case e.PAGE_UP:
      case e.PAGE_DOWN:
        v == null || v();
        break;
    }
  }, R = B(t, d, f, N), b = /* @__PURE__ */ g.createElement("div", W({
    ref: _,
    className: V(u, (i = {}, E(i, "".concat(u, "-").concat(l + 1), F), E(i, "".concat(u, "-dragging"), C), i), U.handle),
    style: x(x(x({}, R), I), T.handle),
    onMouseDown: k,
    onTouchStart: k,
    onKeyDown: G,
    onKeyUp: L,
    tabIndex: c ? null : s(O, l),
    role: "slider",
    "aria-valuemin": f,
    "aria-valuemax": N,
    "aria-valuenow": d,
    "aria-disabled": c,
    "aria-label": s(S, l),
    "aria-labelledby": s(M, l),
    "aria-valuetext": (m = s(K, l)) === null || m === void 0 ? void 0 : m(d),
    "aria-orientation": t === "ltr" || t === "rtl" ? "horizontal" : "vertical"
  }, p));
  return h && (b = h(b, {
    index: l,
    prefixCls: y,
    value: d,
    dragging: C
  })), b;
});
process.env.NODE_ENV !== "production" && (z.displayName = "Handle");
export {
  z as default
};
