import c from "react";
import ee from "../../../classnames/index.mjs";
import te from "../../../rc-slider/es/Slider.mjs";
import { devUseWarning as oe } from "../_util/warning.mjs";
import "../config-provider/index.mjs";
import re from "../config-provider/DisabledContext.mjs";
import le from "./SliderTooltip.mjs";
import ne from "./style/index.mjs";
import { ConfigContext as ie } from "../config-provider/context.mjs";
var se = globalThis && globalThis.__rest || function(e, l) {
  var n = {};
  for (var t in e)
    Object.prototype.hasOwnProperty.call(e, t) && l.indexOf(t) < 0 && (n[t] = e[t]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var i = 0, t = Object.getOwnPropertySymbols(e); i < t.length; i++)
      l.indexOf(t[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[i]) && (n[t[i]] = e[t[i]]);
  return n;
};
function ae(e, l) {
  return e || e === null ? e : l || l === null ? l : (n) => typeof n == "number" ? n.toString() : "";
}
const N = /* @__PURE__ */ c.forwardRef((e, l) => {
  const {
    prefixCls: n,
    range: t,
    className: i,
    rootClassName: j,
    style: S,
    disabled: b,
    // Deprecated Props
    tooltipPrefixCls: _,
    tipFormatter: h,
    tooltipVisible: E,
    getTooltipPopupContainer: V,
    tooltipPlacement: w
  } = e, o = se(e, ["prefixCls", "range", "className", "rootClassName", "style", "disabled", "tooltipPrefixCls", "tipFormatter", "tooltipVisible", "getTooltipPopupContainer", "tooltipPlacement"]), {
    direction: C,
    slider: u,
    getPrefixCls: O,
    getPopupContainer: F
  } = c.useContext(ie), D = c.useContext(re), R = b ?? D, [k, $] = c.useState({}), f = (r, s) => {
    $((a) => Object.assign(Object.assign({}, a), {
      [r]: s
    }));
  }, M = (r, s) => r || (s ? C === "rtl" ? "left" : "right" : "top"), m = O("slider", n), [z, B, I] = ne(m), A = ee(i, u == null ? void 0 : u.className, j, {
    [`${m}-rtl`]: C === "rtl"
  }, B, I);
  C === "rtl" && !o.vertical && (o.reverse = !o.reverse);
  const [G, L] = c.useMemo(() => t ? typeof t == "object" ? [!0, t.draggableTrack] : [!0, !1] : [!1], [t]);
  if (process.env.NODE_ENV !== "production") {
    const r = oe("Slider");
    [["tooltipPrefixCls", "prefixCls"], ["getTooltipPopupContainer", "getPopupContainer"], ["tipFormatter", "formatter"], ["tooltipPlacement", "placement"], ["tooltipVisible", "open"]].forEach((s) => {
      let [a, p] = s;
      r.deprecated(!(a in e), a, `tooltip.${p}`);
    });
  }
  const U = (r, s) => {
    var a;
    const {
      index: p,
      dragging: q
    } = s, {
      tooltip: H = {},
      vertical: J
    } = e, T = Object.assign({}, H), {
      open: g,
      placement: v,
      getPopupContainer: K,
      prefixCls: P,
      formatter: Q
    } = T, x = ae(Q, h), X = x ? k[p] || q : !1, Y = (a = g ?? E) !== null && a !== void 0 ? a : g === void 0 && X, Z = Object.assign(Object.assign({}, r.props), {
      onMouseEnter: () => f(p, !0),
      onMouseLeave: () => f(p, !1),
      onFocus: (y) => {
        var d;
        f(p, !0), (d = o.onFocus) === null || d === void 0 || d.call(o, y);
      },
      onBlur: (y) => {
        var d;
        f(p, !1), (d = o.onBlur) === null || d === void 0 || d.call(o, y);
      }
    });
    return /* @__PURE__ */ c.createElement(le, Object.assign({}, T, {
      prefixCls: O("tooltip", P ?? _),
      title: x ? x(s.value) : "",
      open: Y,
      placement: M(v ?? w, J),
      key: p,
      overlayClassName: `${m}-tooltip`,
      getPopupContainer: K || V || F
    }), /* @__PURE__ */ c.cloneElement(r, Z));
  }, W = Object.assign(Object.assign({}, u == null ? void 0 : u.style), S);
  return z(/* @__PURE__ */ c.createElement(te, Object.assign({}, o, {
    step: o.step,
    range: G,
    draggableTrack: L,
    className: A,
    style: W,
    disabled: R,
    ref: l,
    prefixCls: m,
    handleRender: U
  })));
});
process.env.NODE_ENV !== "production" && (N.displayName = "Slider");
const ve = N;
export {
  ve as default
};
