import * as c from "react";
import P from "../../../classnames/index.mjs";
import { devUseWarning as S } from "../_util/warning.mjs";
import "../config-provider/index.mjs";
import _ from "./style/index.mjs";
import { ConfigContext as M } from "../config-provider/context.mjs";
var V = globalThis && globalThis.__rest || function(r, a) {
  var o = {};
  for (var e in r)
    Object.prototype.hasOwnProperty.call(r, e) && a.indexOf(e) < 0 && (o[e] = r[e]);
  if (r != null && typeof Object.getOwnPropertySymbols == "function")
    for (var n = 0, e = Object.getOwnPropertySymbols(r); n < e.length; n++)
      a.indexOf(e[n]) < 0 && Object.prototype.propertyIsEnumerable.call(r, e[n]) && (o[e[n]] = r[e[n]]);
  return o;
};
const u = (r) => {
  const {
    getPrefixCls: a,
    direction: o,
    divider: e
  } = c.useContext(M), {
    prefixCls: n,
    type: d = "horizontal",
    orientation: s = "center",
    orientationMargin: i,
    className: h,
    rootClassName: v,
    children: l,
    dashed: y,
    plain: O,
    style: b
  } = r, N = V(r, ["prefixCls", "type", "orientation", "orientationMargin", "className", "rootClassName", "children", "dashed", "plain", "style"]), t = a("divider", n), [C, x, $] = _(t), j = s.length > 0 ? `-${s}` : s, m = !!l, f = s === "left" && i != null, p = s === "right" && i != null, E = P(t, e == null ? void 0 : e.className, x, $, `${t}-${d}`, {
    [`${t}-with-text`]: m,
    [`${t}-with-text${j}`]: m,
    [`${t}-dashed`]: !!y,
    [`${t}-plain`]: !!O,
    [`${t}-rtl`]: o === "rtl",
    [`${t}-no-default-orientation-margin-left`]: f,
    [`${t}-no-default-orientation-margin-right`]: p
  }, h, v), g = c.useMemo(() => typeof i == "number" ? i : /^\d+$/.test(i) ? Number(i) : i, [i]), w = Object.assign(Object.assign({}, f && {
    marginLeft: g
  }), p && {
    marginRight: g
  });
  if (process.env.NODE_ENV !== "production") {
    const D = S("Divider");
    process.env.NODE_ENV !== "production" && D(!l || d !== "vertical", "usage", "`children` not working in `vertical` mode.");
  }
  return C(/* @__PURE__ */ c.createElement("div", Object.assign({
    className: E,
    style: Object.assign(Object.assign({}, e == null ? void 0 : e.style), b)
  }, N, {
    role: "separator"
  }), l && d !== "vertical" && /* @__PURE__ */ c.createElement("span", {
    className: `${t}-inner-text`,
    style: w
  }, l)));
};
process.env.NODE_ENV !== "production" && (u.displayName = "Divider");
const k = u;
export {
  k as default
};
